diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-31 17:30:33 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-31 17:30:33 +0100 |
commit | cfae954cb64cefb12cf340ad72e0bc391365ffef (patch) | |
tree | e148e5a1ed0030b48fc9331d0656587c7e9c3f91 /sleepy | |
parent | f18e6072e02ae829498b78712bf15c6b0aedd67c (diff) | |
download | bin-cfae954cb64cefb12cf340ad72e0bc391365ffef.zip bin-cfae954cb64cefb12cf340ad72e0bc391365ffef.tar.gz |
add sleepy
Diffstat (limited to 'sleepy')
-rwxr-xr-x | sleepy | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -0,0 +1,12 @@ +#! /bin/bash +[ $# -lt 1 ] && echo "missing mandatory argument 'hostname'" && exit 1 +host=$1 +ssh $host "sudo halt" || exit 1 +CPT=0 +while [ ${CPT} -ne 5 ]; do + CPT=$((CPT+1)) + ping -c 1 -W 2 -q $host 2>&1 >/dev/null + [ $? -ne 0 ] && echo "sshhh, he's asleep..." && exit 0 + sleep 5 +done +echo "$host is still awake!" && exit 1 |