diff --git a/wol/scripts/wakeonlanservice.sh b/wol/scripts/wakeonlanservice.sh index 96ee0b63f91e4bf5a975f0fa1944d154edd03f7b..6a5b53f413c4022f0edbba44041e5090655357ce 100755 --- a/wol/scripts/wakeonlanservice.sh +++ b/wol/scripts/wakeonlanservice.sh @@ -16,6 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +getip(){ + awk '/^lease/{IP=$2} /hardware ethernet/{gsub(";","",$3);if($3 == "'$1'"){print $3}}' \ + < /var/lib/dhcp/dhcpd.leases +} + IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1) broadcast=$(ip a | awk '/inet.*eth1/ {print $4}' | cut -d / -f 1) subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3) @@ -25,7 +30,7 @@ netcat -k -l $IP 9999 | \ if [ $(echo "$MAC" | egrep -c "^([0-9a-f]{2}:?){6}$") -eq 1 ] then wakeonlan -i $broadcast "$MAC" - bootedip=`arp | grep "$MAC" | awk '{print $1}'` + bootedip=`getip $MAC` echo "$bootedip" | netcat $subnet.51 9999 fi done