Files
backup_nuc/wake_probook.sh
Thomas Klaehn a75a4a8579 adapt to p5
Signed-off-by: Thomas Klaehn <tkl@blackfinn.de>
2025-10-02 15:19:54 +02:00

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