diff options
Diffstat (limited to 'shutdownasap.in')
-rwxr-xr-x | shutdownasap.in | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/shutdownasap.in b/shutdownasap.in new file mode 100755 index 0000000..0afd586 --- /dev/null +++ b/shutdownasap.in @@ -0,0 +1,67 @@ +#!/bin/bash + +# shutdownasap version #VERSION# + +. #ETCDIR#/shutdownasap.conf + +[ -r "${pidFile}" ] && ps aux | grep -q "^\S\+\s\+$(cat "${pidFile}") " && exit + +echo $$ > "${pidFile}" + +beforeWatchHook + +i=1 +while [ ${i} -gt 0 ] +do + sleep 1 + prozesse="$(ps aux | grep -v grep)" + + nochwarten=false + + if [ -d "${waitForDir}" ] && ls -1A "${waitForDir}" | grep -q "." + then + nochwarten=true + echo ".warteauf: " + ls -1A "${waitForDir}" + fi + + if users | grep -q "." + then + nochwarten=true + echo -n "users: " + users + fi + + for synActFile in /sys/block/md*/md/sync_action + do + if [ -r "${synActFile}" ] && ! grep -q "^idle\$" "${synActFile}" + then + nlochWarten=true + echo -n "raid ${synActFile}: " + cat "${synActFile}" + fi + done + + for s in "${!shutDownNoGos[@]}" + do + if [ -e "${shutDownNoGos[${s}]}" ] || echo "${prozesse}" | grep -q "\(\s\|/\)${shutDownNoGos[${s}]}\(\$\|\s\)" + then + nochwarten=true + echo "prozess: ${s}" + fi + done + + if ${nochwarten} + then + echo "warten ..." + i=10 + continue + else + echo "noch ${i} Sekunden" + fi + i=$[${i}-1] +done + +beforeShutDownHook + +sudo /sbin/poweroff |