NetworkManager and Wol (WakeOnLAN)

That one little moment when the last of the systems that had failed for years to wake up on LAN finally gives up and does the job. I literally have no idea what went wrong on this little media station in the past, but a fresh install of Opensuse Tumbleweed fixed it. We’ve been looking into the BIOS so many times, systematically, comparing with its twin sibling, didn’t find a mistake. And also the NetworkManager dispatcher script was installed. I gave up and did a fresh Linux install. All I had to do then was adding this script: 

#!/bin/bash
# /etc/NetworkManager/dispatcher.d/wol
#
#
# wol dispatcher script for NetworkManager
#
#
IFNAME=enp2s0
if [ $2 = “up” -a $1 = $IFNAME ]; then
sleep 2
/usr/sbin/ethtool -s $IFNAME wol g
fi

… and make it executable (chmod a+x), done. Oh, make sure that the line starting with “IFNAME” (line 8) contains YOUR device’s name, not the random generated by your distributor and that the script really ends up in /etc/NetworkManager/dispatcher.d/wol.

Now my little upgrade script (don’t do this on production machines!) wakes up and updates the media station every morning while we are sleeping (all relevant data changed):

#!/bin/bash
# /usr/sbin/wakeup-update-mediastation
#
# Wakeup and update MediaStation
wol a8:a1:23:3e:g7:39
sleep60
ssh 192.168.0.222 ‘sudo zypper ref && sudo zypper dup -y -l –allow-vendor-change
sleep20
ssh 192.168.0.222 ‘sudo sync; sudo poweroff
logger Mediastation successfully updated

It’s invoked by the cron job: 

0 6 * * * /usr/sbin/wakeup-update-mediastation

Your mileage may vary when it comes to user priviledges (sudo or ssh as root, make sure you do the right thing!)