Skip to content

Instantly share code, notes, and snippets.

@junielton
Forked from izaya-ux/Wake on lan
Created July 3, 2021 19:18
Show Gist options
  • Select an option

  • Save junielton/691a9b494a3e6df7d591454741357f15 to your computer and use it in GitHub Desktop.

Select an option

Save junielton/691a9b494a3e6df7d591454741357f15 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