summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-04-10 11:21:56 +0200
committerErich Eckner <git@eckner.net>2016-04-10 11:21:56 +0200
commitee45f2e79c67d17ba4c0a67617d6a08f85af085e (patch)
tree225f2372da27fbfac6a287a95e22ff7cef5fd046
parent4eb26ade00c26cee4a112fa8e4113b1699357d99 (diff)
downloadshutdownasap-ee45f2e79c67d17ba4c0a67617d6a08f85af085e.tar.xz
skripte soweit erstmal fertigv0.0
-rwxr-xr-xshutdownasap23
-rwxr-xr-xshutdownasap.conf20
2 files changed, 29 insertions, 14 deletions
diff --git a/shutdownasap b/shutdownasap
index e921b84..366b1f0 100755
--- a/shutdownasap
+++ b/shutdownasap
@@ -1,8 +1,10 @@
#!/bin/bash
-[ -e /tmp/shutdownasap.pid ] && ps aux | grep -q "^[^ ]* *$(cat /tmp/shutdownasap.pid) " && exit
+. /etc/shutdownasap.conf
-echo $$ > /tmp/shutdownasap.pid
+[ -r "${pidFile}" ] && ps aux | grep -q "^\S\+\s\+$(cat "${pidFile}") " && exit
+
+echo $$ > "${pidFile}"
i=1
while [ ${i} -gt 0 ]
@@ -12,11 +14,11 @@ do
nochwarten=false
- if ls -1A /home/shutdown/.warteauf | grep -q "."
+ if ls -1A "${waitForDir}" | grep -q "."
then
nochwarten=true
echo ".warteauf: "
- ls -1A /home/shutdown/.warteauf
+ ls -1A "${waitForDir}"
fi
if users | grep -q "."
@@ -36,10 +38,9 @@ do
fi
done
- for s in $(cat /etc/shutdownnogo)
+ for s in "${!shutDownNoGos[@]}"
do
- [ "${s}" == "backup" ] && t="${s}" || t="${s}\(\$\|\s\)"
- if echo "${prozesse}" | grep -q "\(\s\|/\)${t}\(\$\|\s\)"
+ if echo "${prozesse}" | grep -q "\(\s\|/\)${shutDownNoGos[${s}]}\(\$\|\s\)"
then
nochwarten=true
echo "prozess: ${s}"
@@ -57,12 +58,6 @@ do
i=$[${i}-1]
done
-if ping 192.168.0.15 -c1 &> /dev/null
-then
- if ssh shutdown@192.168.0.15 ls -1 /home/shutdown/.warteauf | grep -q "^192\.168\.0\.18\$"
- then
- ssh shutdown@192.168.0.15 rm /home/shutdown/.warteauf/192.168.0.18
- fi
-fi
+beforeShutDownHook
sudo /sbin/poweroff
diff --git a/shutdownasap.conf b/shutdownasap.conf
new file mode 100755
index 0000000..4ff6198
--- /dev/null
+++ b/shutdownasap.conf
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+
+pidFile="/tmp/shutdownasap.pid"
+waitForDir="/home/shutdown/.warteauf"
+
+declare -A shutDownNoGos
+
+shutDownNoGos["rsync"]="rsync"
+shutDownNoGos["backup"]="[^/ ]*backup"
+shutDownNoGos["prt-get"]="prt-get"
+shutDownNoGos["ports"]="ports"
+shutDownNoGos["rsync"]="rsync"
+shutDownNoGos["wget"]="wget"
+shutDownNoGos["dd"]="dd"
+shutDownNoGos["ncat"]="ncat"
+
+beforeShutDownHook() {
+ true
+}