#!/bin/bash [ -e /tmp/shutdownasap.pid ] && ps aux | grep -q "^[^ ]* *$(cat /tmp/shutdownasap.pid) " && exit echo $$ > /tmp/shutdownasap.pid i=1 while [ ${i} -gt 0 ] do sleep 1 prozesse="$(ps aux | grep -v grep)" nochwarten=false if ls -1A /home/shutdown/.warteauf | grep -q "." then nochwarten=true echo ".warteauf: " ls -1A /home/shutdown/.warteauf 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 $(cat /etc/shutdownnogo) do [ "${s}" == "backup" ] && t="${s}" || t="${s}\(\$\|\s\)" if echo "${prozesse}" | grep -q "\(\s\|/\)${t}\(\$\|\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 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 sudo /sbin/poweroff