Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait_for_reboot() {
- cnt=0
- host=$1
- start=`date +%s`
- ping -c 1 -n -w 1 $host | grep "1 received" > /dev/null
- [ $? != 0 ] && status=down || status=up
- [ "$2" == "" ] && timeout=90 || timeout=$2
- echo -en "\nWaiting for target host \"$host\" to reboot."
- while true; do
- ping -c 1 -n -w 1 $host | grep "0 received" > /dev/null
- result=$?
- echo -n "."
- cnt=$((cnt+1))
- [ $result == 1 ] && sleep 1 || status=down
- [ $result == 1 ] && [ $status == "down" ] && {
- sleep 1
- end=`date +%s`
- echo -e "Done\n\nHost \"$host\" is back online, reboot time: $(format_time1 $[end-start])"
- break
- } || [ $cnt -ge $timeout ] && {
- echo -e "\nRemote host \"$host\" did not reboot. [timeout > $timeout]\n"
- break
- }
- done
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement