Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace fstab by explicit systemd mount units to ensure proper order #807

Merged
merged 2 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions functions/system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 13 additions & 0 deletions includes/mount_template
Original file line number Diff line number Diff line change
@@ -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

84 changes: 42 additions & 42 deletions includes/smb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down