Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: toggle-wol ujust script now dynamically detects active network interface on run #2333

Merged
merged 9 commits into from
Mar 7, 2025
1 change: 1 addition & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ RUN --mount=type=cache,dst=/var/cache/libdnf5 \
systemctl --global enable systemd-tmpfiles-setup.service && \
systemctl --global disable sunshine.service && \
systemctl disable waydroid-container.service && \
systemctl disable force-wol.service && \
curl -Lo /etc/dxvk-example.conf https://raw.githubusercontent.com/doitsujin/dxvk/master/dxvk.conf && \
curl -Lo /usr/bin/waydroid-choose-gpu https://raw.githubusercontent.com/KyleGospo/waydroid-scripts/main/waydroid-choose-gpu.sh && \
chmod +x /usr/bin/waydroid-choose-gpu && \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Force Enable Wake-on-LAN
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/force-wol

[Install]
WantedBy=network-online.target
5 changes: 5 additions & 0 deletions system_files/desktop/shared/usr/libexec/force-wol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/bash
INTERFACE=$(ip link show | awk '/state UP/ {print $2}' | tr -d ':' | grep -E '^(en|eth)')
if [ -n "$INTERFACE" ]; then
/sbin/ethtool -s $INTERFACE wol g
fi
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,21 @@ toggle-wol:
echo "Removing udev rule to disable persistence..."
sudo rm -f "$CONFIG_FILE"
fi
if systemctl is-enabled force-wol.service &>/dev/null; then
sudo systemctl disable force-wol.service
echo "Force-WOL service has been disabled."
fi
echo "Wake-on-LAN has been ${red}${bold}disabled${normal}."
elif [[ "${OPTION,,}" == "create-service" ]]; then
echo "You chose to create a systemd service for enabling WOL at boot."
echo "You chose to enable wake on LAN at boot."
echo "Requesting root privileges..."
sudo bash -c "cat > $SERVICE_FILE <<EOF
[Unit]
Description=Force Enable Wake-on-LAN
After=network-online.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s $INTERFACE wol g
[Install]
WantedBy=network-online.target
EOF"
if [ -f "/etc/systemd/system/force-wol.service" ]; then
echo "Removing deprecated service file"
sudo rm "/etc/systemd/system/force-wol.service"
fi
sudo systemctl daemon-reload
sudo systemctl enable --now force-wol.service
echo "Systemd service created and enabled at boot: ${green}${bold}force-wol.service${normal}"
echo "Wake on LAN enabled at boot: ${green}${bold}force-wol.service${normal}"
else
echo "No changes were made."
fi
Expand Down