Skip to content

Commit

Permalink
nc-automount: add delays to some services in a persistent way
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Jan 15, 2019
1 parent 6fb9c9b commit 34cba9f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
3 changes: 0 additions & 3 deletions bin/ncp/NETWORKING/NFS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ install()
apt-get install --no-install-recommends -y nfs-kernel-server
systemctl disable nfs-kernel-server
systemctl mask nfs-blkmap

# delay init because of automount
sed -i 's|^ExecStartPre=.*|ExecStartPre=/bin/bash -c "/bin/sleep 30; /usr/sbin/exportfs -r"|' /lib/systemd/system/nfs-server.service
}

configure()
Expand Down
3 changes: 0 additions & 3 deletions bin/ncp/SECURITY/fail2ban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ EOF
grep -q actionstart_ "$F" || sed -i 's|actionstart|actionstart_|' "$F"
grep -q actionstop_ "$F" || sed -i 's|actionstop|actionstop_|' "$F"

# delay init because of automount
sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" /lib/systemd/system/fail2ban.service

}

configure()
Expand Down
34 changes: 30 additions & 4 deletions bin/ncp/SYSTEM/nc-automount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ inotifywait --monitor --event create --event delete --format '%f %e' /media/ | \
done
EOF
chmod +x /usr/local/etc/nc-automount-links-mon

# delay init because of automount
sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 20" /lib/systemd/system/mariadb.service
sed -i 's|^Restart=.*|Restart=on-failure|' /lib/systemd/system/mariadb.service
}

configure()
Expand All @@ -93,13 +89,43 @@ configure()
systemctl stop nc-automount-links
systemctl disable nc-automount
systemctl disable nc-automount-links
rm -rf /etc/systemd/system/{mariadb,nfs-server,dphys-swapfile,fail2ban}.service.d
systemctl daemon-reload
echo "automount disabled"
return 0
}
systemctl enable nc-automount
systemctl enable nc-automount-links
systemctl start nc-automount
systemctl start nc-automount-links

# create delays in some units
mkdir -p /etc/systemd/system/mariadb.service.d
cat > /etc/systemd/system/mariadb.service.d/ncp-delay-automount.conf <<'EOF'
[Service]
ExecStartPre=/bin/sleep 20
Restart=on-failure
EOF

mkdir -p /etc/systemd/system/nfs-server.service.d
cat > /etc/systemd/system/nfs-server.service.d/ncp-delay-automount.conf <<'EOF'
[Service]
ExecStartPre=/bin/bash -c "/bin/sleep 30; /usr/sbin/exportfs -r"
EOF

mkdir -p /etc/systemd/system/dphys-swapfile.service.d
cat > /etc/systemd/system/dphys-swapfile.service.d/ncp-delay-automount.conf <<'EOF'
[Service]
ExecStartPre=/bin/sleep 30
EOF

mkdir -p /etc/systemd/system/fail2ban.service.d
cat > /etc/systemd/system/fail2ban.service.d/ncp-delay-automount.conf <<'EOF'
[Service]
ExecStartPre=/bin/sleep 10
EOF

systemctl daemon-reload
echo "automount enabled"
}

Expand Down
2 changes: 0 additions & 2 deletions bin/ncp/SYSTEM/nc-swapfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ install()
{
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends dphys-swapfile
# delay init because of automount
sed -i "/\<start)/asleep 30" /etc/init.d/dphys-swapfile
}


Expand Down
6 changes: 4 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

[v1.3.5](https://github.com/nextcloud/nextcloudpi/commit/7697a4d) (2019-01-14) nc-hdd-test: try to detect device type if auto doesnt work
[v1.3.6](https://github.com/nextcloud/nextcloudpi/commit/fc80dc9) (2019-01-14) nc-automount: add delays to some services in a persistent way

[v1.3.4](https://github.com/nextcloud/nextcloudpi/commit/9b1ecbb) (2019-01-14) nc-info: fix automount reporting
[v1.3.5](https://github.com/nextcloud/nextcloudpi/commit/6fb9c9b) (2019-01-14) nc-hdd-test: try to detect device type if auto doesnt work

[v1.3.4 ](https://github.com/nextcloud/nextcloudpi/commit/9b1ecbb) (2019-01-14) nc-info: fix automount reporting

[v1.3.3 ](https://github.com/nextcloud/nextcloudpi/commit/389ed0c) (2019-01-14) nc-ramlog: adapt to armbian

Expand Down

0 comments on commit 34cba9f

Please sign in to comment.