summaryrefslogtreecommitdiffstats
path: root/remote/modules/systemd/data
diff options
context:
space:
mode:
Diffstat (limited to 'remote/modules/systemd/data')
-rw-r--r--remote/modules/systemd/data/etc/systemd/system/systemd-halt.service18
-rw-r--r--remote/modules/systemd/data/etc/systemd/system/systemd-poweroff.service18
-rw-r--r--remote/modules/systemd/data/etc/systemd/system/systemd-reboot.service18
-rwxr-xr-xremote/modules/systemd/data/opt/openslx/scripts/systemd-shutdown_prescript53
4 files changed, 107 insertions, 0 deletions
diff --git a/remote/modules/systemd/data/etc/systemd/system/systemd-halt.service b/remote/modules/systemd/data/etc/systemd/system/systemd-halt.service
new file mode 100644
index 00000000..95b4f284
--- /dev/null
+++ b/remote/modules/systemd/data/etc/systemd/system/systemd-halt.service
@@ -0,0 +1,18 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Halt
+Documentation=man:systemd-halt.service(8)
+DefaultDependencies=no
+Requires=shutdown.target final.target
+After=shutdown.target final.target
+
+[Service]
+Type=oneshot
+ExecStartPre=-/bin/bash -c /opt/openslx/scripts/systemd-shutdown_prescript
+ExecStart=/usr/bin/systemctl --force halt
diff --git a/remote/modules/systemd/data/etc/systemd/system/systemd-poweroff.service b/remote/modules/systemd/data/etc/systemd/system/systemd-poweroff.service
new file mode 100644
index 00000000..8b96980e
--- /dev/null
+++ b/remote/modules/systemd/data/etc/systemd/system/systemd-poweroff.service
@@ -0,0 +1,18 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Power-Off
+Documentation=man:systemd-halt.service(8)
+DefaultDependencies=no
+Requires=shutdown.target final.target
+After=shutdown.target final.target
+
+[Service]
+Type=oneshot
+ExecStartPre=-/bin/bash -c /opt/openslx/scripts/systemd-shutdown_prescript
+ExecStart=/usr/bin/systemctl --force poweroff
diff --git a/remote/modules/systemd/data/etc/systemd/system/systemd-reboot.service b/remote/modules/systemd/data/etc/systemd/system/systemd-reboot.service
new file mode 100644
index 00000000..be4d608c
--- /dev/null
+++ b/remote/modules/systemd/data/etc/systemd/system/systemd-reboot.service
@@ -0,0 +1,18 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Reboot
+Documentation=man:systemd-halt.service(8)
+DefaultDependencies=no
+Requires=shutdown.target final.target
+After=shutdown.target final.target
+
+[Service]
+Type=oneshot
+ExecStartPre=-/bin/bash -c /opt/openslx/scripts/systemd-shutdown_prescript
+ExecStart=/usr/bin/systemctl --force reboot
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