From cfae954cb64cefb12cf340ad72e0bc391365ffef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 31 Jan 2012 17:30:33 +0100 Subject: add sleepy --- sleepy | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 sleepy diff --git a/sleepy b/sleepy new file mode 100755 index 0000000..078299b --- /dev/null +++ b/sleepy @@ -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 -- cgit v1.1-2-g2b99