From ee45f2e79c67d17ba4c0a67617d6a08f85af085e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 10 Apr 2016 11:21:56 +0200 Subject: skripte soweit erstmal fertig --- shutdownasap | 23 +++++++++-------------- shutdownasap.conf | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 14 deletions(-) create mode 100755 shutdownasap.conf 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 +} -- cgit v1.2.3-54-g00ecf