summaryrefslogtreecommitdiffstats
path: root/remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript
diff options
context:
space:
mode:
authorManuel Schneider2014-11-26 12:21:45 +0100
committerManuel Schneider2014-11-26 12:21:45 +0100
commit63fa049f2332c1b7a19d61a4a04f537142c8a787 (patch)
tree36295b8e35844e2491f5b3d5356d3617d45f7c10 /remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript
parent[PVS2] Remove unexpected 'fi' (diff)
parent[rfs-stage31] Write IP information to /opt/openslx/config even if config.tgz ... (diff)
downloadtm-scripts-63fa049f2332c1b7a19d61a4a04f537142c8a787.tar.gz
tm-scripts-63fa049f2332c1b7a19d61a4a04f537142c8a787.tar.xz
tm-scripts-63fa049f2332c1b7a19d61a4a04f537142c8a787.zip
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript')
-rwxr-xr-xremote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript50
1 files changed, 50 insertions, 0 deletions
diff --git a/remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript b/remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript
new file mode 100755
index 00000000..3b5d7f92
--- /dev/null
+++ b/remote/modules/systemd-distro/data/opt/openslx/scripts/systemd-shutdown_prescript
@@ -0,0 +1,50 @@
+#!/bin/ash
+
+# This script gets called by ExecStartPre from the services
+# systemd-halt, systemd-poweroff, systemd-reboot. Pre-shutdown actions as
+# unmounting nfs shares etc. should go here.
+
+PATH=/bin:/usr/bin:/opt/openslx/bin
+
+# kill leftover processes
+
+umount_nfs_shares() {
+ for i in "$(mount | grep 'type nfs')"; do
+ share=$(echo "$i"|cut -f 3 -d " ")
+ echo "Unmounte nfs-Share $share ...."
+ umount "$share"
+ ERROR=$?
+ if [ $ERROR -eq 0 ]; then
+ echo "nfs-Share $share unmounted."
+ else
+ echo "Could not umount nfs share $share!"
+ ERRORLEVEL=1
+ fi
+ done
+}
+
+umount_samba_shares() {
+ for i in "$(mount | grep 'type cifs')"; do
+ share=$(echo $i|cut -f 3 -d " ")
+ echo "Unmounte cifs-Share $share ...."
+ umount "$share"
+ ERROR=$?
+ if [ $ERROR -eq 0 ]; then
+ echo "cifs-Share $share unmounted."
+ else
+ echo "Could not umount cifs share $share!"
+ ERRORLEVEL=1
+ fi
+ done
+}
+
+# Searching for nfs-shares in mtab:
+if [ $(echo /etc/mtab | cut -d " " -f 3 | grep -q nfs) ]; then
+ umount_nfs_shares
+fi
+
+# Searching for samba-shares:
+if [ $(echo /etc/mtab|cut -d " " -f 3 | grep -q cifs) ]; then
+ umount_samba_shares
+fi
+exit $ERRORLEVEL