diff options
| author | Christian Rößler | 2013-10-07 15:49:22 +0200 |
|---|---|---|
| committer | Christian Rößler | 2013-10-07 15:49:22 +0200 |
| commit | 45914431f11ceecbf0963af0005493bd6c8a109d (patch) | |
| tree | 73d08d0e7c04492ba1f2e4c8b9e61d86619f93ad /remote/modules/systemd/data/opt/openslx/scripts | |
| parent | Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff) | |
| download | tm-scripts-45914431f11ceecbf0963af0005493bd6c8a109d.tar.gz tm-scripts-45914431f11ceecbf0963af0005493bd6c8a109d.tar.xz tm-scripts-45914431f11ceecbf0963af0005493bd6c8a109d.zip | |
[systemd] Amended shutdown behaviour for systemd: reboot, halt, poweroff. nfs
and samba (cifs) umount script hooked via ExecStartPre; script will include kill
routines etc. later on for faster shutdowns. Patched services r/h/s.
Diffstat (limited to 'remote/modules/systemd/data/opt/openslx/scripts')
| -rwxr-xr-x | remote/modules/systemd/data/opt/openslx/scripts/systemd-shutdown_prescript | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/remote/modules/systemd/data/opt/openslx/scripts/systemd-shutdown_prescript b/remote/modules/systemd/data/opt/openslx/scripts/systemd-shutdown_prescript new file mode 100755 index 00000000..d51500e9 --- /dev/null +++ b/remote/modules/systemd/data/opt/openslx/scripts/systemd-shutdown_prescript @@ -0,0 +1,53 @@ +#!/bin/bash + +# 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 + +# Prozesse killen + +# rein zur Detektion des Skriptstarts: +ping -c 3 132.230.8.69 + +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 |
