diff --git a/functions/system.bash b/functions/system.bash index 70c9656ac..39969f9a3 100644 --- a/functions/system.bash +++ b/functions/system.bash @@ -134,23 +134,33 @@ vimrc_copy() { echo "OK" } +create_mount() { + F=/etc/systemd/system/$(systemd-escape --path /srv/openhab2-"${2}").mount + sed -e "s|%SRC|$1|g" -e "s|%DEST|$2|g" "$BASEDIR"/includes/mount_template > "$F" + systemctl -q enable "srv-openhab2\\x2d$2.mount" + systemctl -q start "srv-openhab2\\x2d$2.mount" +} + srv_bind_mounts() { echo -n "$(timestamp) [openHABian] Preparing openHAB folder mounts under /srv/... " + systemctl is-active --quiet smbd && systemctl stop smbd + systemctl is-active --quiet zram-config && systemctl stop zram-config + cond_redirect umount -q /srv/openhab2-{sys,conf,userdata,logs,addons} sed -i "\\#[ \\t]/srv/openhab2-#d" /etc/fstab - sed -i "/^$/d" /etc/fstab - ( echo "" - echo "/usr/share/openhab2 /srv/openhab2-sys none bind 0 0" - echo "/etc/openhab2 /srv/openhab2-conf none bind 0 0" - echo "/var/lib/openhab2 /srv/openhab2-userdata none bind 0 0" - echo "/var/log/openhab2 /srv/openhab2-logs none bind 0 0" - echo "/usr/share/openhab2/addons /srv/openhab2-addons none bind 0 0" - ) >> /etc/fstab # dummy" to fix vim coloring - - cond_redirect cat /etc/fstab + # dummy " to fix vim coloring + cond_redirect rm -f /etc/systemd/system/srv*.mount cond_redirect mkdir -p /srv/openhab2-{sys,conf,userdata,logs,addons} cond_redirect cp "$BASEDIR"/includes/srv_readme.txt /srv/README.txt cond_redirect chmod ugo+w /srv /srv/README.txt - if cond_redirect mount --all --verbose; then echo "OK"; else echo "FAILED"; fi + + cond_redirect create_mount /usr/share/openhab2 sys + cond_redirect create_mount /etc/openhab2 conf + cond_redirect create_mount /var/lib/openhab2 userdata + cond_redirect create_mount /var/log/openhab2 logs + cond_redirect create_mount /usr/share/openhab2/addons addons + + if [ -f /etc/ztab ]; then systemctl start zram-config; fi + if [ -f /etc/samba/smb.conf ]; then systemctl start smbd; fi } permissions_corrections() { diff --git a/includes/mount_template b/includes/mount_template new file mode 100644 index 000000000..b88e0d92b --- /dev/null +++ b/includes/mount_template @@ -0,0 +1,13 @@ +[Unit] +Description=openhab2-%DEST mount +After=zram-config.service + +[Mount] +What=%SRC +Where=/srv/openhab2-%DEST +Type=none +Options=bind + +[Install] +WantedBy=multi-user.target + diff --git a/includes/smb.conf b/includes/smb.conf index 04862c257..c9c1c352d 100644 --- a/includes/smb.conf +++ b/includes/smb.conf @@ -183,33 +183,33 @@ #======================= Share Definitions ======================= -[homes] - comment = Home Directories - browseable = no - valid users = %S - writeable = yes - create mask = 0700 - directory mask = 0700 - -[printers] - comment = All Printers - browseable = no - public = no - path = /var/spool/samba - printable = yes - guest ok = no - read only = yes - create mask = 0700 +;[homes] +; comment = Home Directories +; browseable = no +; valid users = %S +; writeable = yes +; create mask = 0700 +; directory mask = 0700 + +;[printers] +; comment = All Printers +; browseable = no +; public = no +; path = /var/spool/samba +; printable = yes +; guest ok = no +; read only = yes +; create mask = 0700 # Windows clients look for this share name as a source of downloadable # printer drivers -[print$] - comment = Printer Drivers - path = /var/lib/samba/printers - browseable = no - public = no - read only = yes - guest ok = no +;[print$] +; comment = Printer Drivers +; path = /var/lib/samba/printers +; browseable = no +; public = no +; read only = yes +; guest ok = no # Uncomment to allow remote administration of Windows print drivers. # You may need to replace 'lpadmin' with the name of the group your # admin users are members of. @@ -219,15 +219,15 @@ #=================== Custom Share Definitions ==================== -[openHAB-share] - comment=openHAB2 combined folders - path=/srv - writeable=yes - public=no - create mask=0664 - directory mask=0775 - veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/._*/ - delete veto files = yes +;[openHAB-share] +; comment=openHAB2 combined folders +; path=/srv +; writeable=yes +; public=no +; create mask=0664 +; directory mask=0775 +; veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/._*/ +; delete veto files = yes [openHAB-conf] comment=openHAB2 site configuration @@ -259,15 +259,15 @@ ; veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/._*/ ; delete veto files = yes -;[openHAB-log] -; comment=openHAB2 log files -; path=/var/log/openhab2 -; writeable=yes -; public=no -; create mask=0664 -; directory mask=0775 -; veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/._*/ -; delete veto files = yes +[openHAB-logs] + comment=openHAB2 log files + path=/var/log/openhab2 + writeable=yes + public=no + create mask=0664 + directory mask=0775 + veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/._*/ + delete veto files = yes ;[var-www] ; comment=webserver files