39 lines
673 B
Bash
Executable File
39 lines
673 B
Bash
Executable File
#!/bin/sh
|
|
host=probook
|
|
host_mac=2c:41:38:08:6c:44
|
|
timeout=1
|
|
|
|
# when no count parameter is set use 1
|
|
if [ $# -ne 0 ]; then
|
|
timeout=$1
|
|
fi
|
|
|
|
echo -n "Checking if $host is already alive... "
|
|
ping -c 1 $host >/dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo "yes. Done"
|
|
exit 0
|
|
fi
|
|
echo "no."
|
|
|
|
echo -n "Trying to wake up $host ($timeout) ... "
|
|
|
|
while [ $timeout -gt 0 ]; do
|
|
# wol $host_mac >/dev/null 2>&1
|
|
wakeonlan $host_mac >/dev/null 2>&1
|
|
ping -c 1 $host >/dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo "success."
|
|
exit 0
|
|
fi
|
|
((timeout=timeout-1))
|
|
sleep 1
|
|
echo "no."
|
|
echo -n "Re-trying to wake up $host ($timeout) ... "
|
|
done
|
|
|
|
echo "no."
|
|
echo "Unable to wake up $host"
|
|
exit 1
|
|
|