Skip to content

Instantly share code, notes, and snippets.

@izaya-ux
Created December 30, 2020 21:59
Show Gist options
  • Save izaya-ux/89f6bfdfc941a569c149255cbad7a68c to your computer and use it in GitHub Desktop.
Save izaya-ux/89f6bfdfc941a569c149255cbad7a68c to your computer and use it in GitHub Desktop.
Wake on lan (Wol) how to use an alexa device to turn on and off your ubuntu linux pc
Wake on lan (Wol) how to use an alexa device to turn on and off your ubuntu linux pc
https://www.wolskill.com
sudo su
apt install wakeonlan
apt install ethtool
(Find your ethernet adapter, mine was called 'enp4s0' (usually called 'eth0').)
ifconfig -a
ethtool enp4s0
(Non-interactive creation of script which will set the "Wake-on" option to "g" which means "Wake on MagicPacket". )
cat >> /root/wol_fix.sh <<EOF
(paste into file)
#!/bin/bash
ethtool -s enp4s0 wol g
EOF
(Set correct permissions for the fix script.)
chmod 755 /root/wol_fix.sh
(Non-interactive creation of script which will run on boot to run the fixing script.)
cat >> /etc/systemd/system/wol_fix.service <<EOF
(paste into file)
[Unit]
Description=Fix WakeOnLAN being reset to disabled on shutdown
[Service]
ExecStart=/root/wol_fix.sh
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
(Reload the systemd manager configuration.)
systemctl daemon-reload
(Enable to wol_fix service script.)
systemctl enable wol_fix.service
restart now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment