Skip to content

Commit 088334f

Browse files
feat: toggle-wol ujust script now dynamically detects active network interface on run (ublue-os#2333)
* feat: toggle-wol ujust script now dynamically detects active network interface on run * feat: add service, disable in containerfile, adj toggle wol ujust * feat: adj containerfile, add system file for force-wol * Update 81-bazzite-fixes.just Co-authored-by: HikariKnight <2557889+HikariKnight@users.noreply.github.com> * fix: changed wording of enable at boot option for wol * fix: make force-wol executable * fix: populate force-wol * fix: make wol executable * fix: change wording for clarity --------- Co-authored-by: HikariKnight <2557889+HikariKnight@users.noreply.github.com>
1 parent cf253fa commit 088334f

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Containerfile

+1
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ RUN --mount=type=cache,dst=/var/cache/libdnf5 \
639639
systemctl --global enable systemd-tmpfiles-setup.service && \
640640
systemctl --global disable sunshine.service && \
641641
systemctl disable waydroid-container.service && \
642+
systemctl disable force-wol.service && \
642643
curl -Lo /etc/dxvk-example.conf https://raw.githubusercontent.com/doitsujin/dxvk/master/dxvk.conf && \
643644
curl -Lo /usr/bin/waydroid-choose-gpu https://raw.githubusercontent.com/KyleGospo/waydroid-scripts/main/waydroid-choose-gpu.sh && \
644645
chmod +x /usr/bin/waydroid-choose-gpu && \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Force Enable Wake-on-LAN
3+
After=network-online.target
4+
5+
[Service]
6+
Type=oneshot
7+
ExecStart=/usr/libexec/force-wol
8+
9+
[Install]
10+
WantedBy=network-online.target
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
INTERFACE=$(ip link show | awk '/state UP/ {print $2}' | tr -d ':' | grep -E '^(en|eth)')
3+
if [ -n "$INTERFACE" ]; then
4+
/sbin/ethtool -s $INTERFACE wol g
5+
fi

system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just

+14-16
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ toggle-wol:
107107
CURRENT_STATE="Enabled"
108108
fi
109109
echo "Wake-on-LAN is currently: ${bold}${CURRENT_STATE}${normal}"
110-
echo "Enable, Disable Wake-on-LAN, Create Service, or Exit without saving?"
111-
echo "Note: Create service if Enabling is not persistent."
112-
OPTION=$(ugum choose Enable Disable Create-Service Exit)
110+
echo "Enable, Disable Wake-on-LAN, Force-Enable, or Exit without saving?"
111+
echo "Note: Force-Enable will make WOL persist across reboots"
112+
OPTION=$(ugum choose Enable Disable Force-Enable Exit)
113113
if [[ "${OPTION,,}" == "enable" ]]; then
114114
echo "You chose to enable Wake-on-LAN."
115115
echo "Requesting root privileges..."
@@ -127,23 +127,21 @@ toggle-wol:
127127
echo "Removing udev rule to disable persistence..."
128128
sudo rm -f "$CONFIG_FILE"
129129
fi
130+
if systemctl is-enabled force-wol.service &>/dev/null; then
131+
sudo systemctl disable force-wol.service
132+
echo "Force-WOL service has been disabled."
133+
fi
130134
echo "Wake-on-LAN has been ${red}${bold}disabled${normal}."
131-
elif [[ "${OPTION,,}" == "create-service" ]]; then
132-
echo "You chose to create a systemd service for enabling WOL at boot."
135+
elif [[ "${OPTION,,}" == "force-enable" ]]; then
136+
echo "You chose to force-enable wake on LAN."
133137
echo "Requesting root privileges..."
134-
sudo bash -c "cat > $SERVICE_FILE <<EOF
135-
[Unit]
136-
Description=Force Enable Wake-on-LAN
137-
After=network-online.target
138-
[Service]
139-
Type=oneshot
140-
ExecStart=/sbin/ethtool -s $INTERFACE wol g
141-
[Install]
142-
WantedBy=network-online.target
143-
EOF"
138+
if [ -f "/etc/systemd/system/force-wol.service" ]; then
139+
echo "Removing deprecated service file"
140+
sudo rm "/etc/systemd/system/force-wol.service"
141+
fi
144142
sudo systemctl daemon-reload
145143
sudo systemctl enable --now force-wol.service
146-
echo "Systemd service created and enabled at boot: ${green}${bold}force-wol.service${normal}"
144+
echo "Wake on LAN force-enabled: ${green}${bold}force-wol.service${normal}"
147145
else
148146
echo "No changes were made."
149147
fi

0 commit comments

Comments
 (0)