@@ -107,9 +107,9 @@ toggle-wol:
107
107
CURRENT_STATE ="Enabled"
108
108
fi
109
109
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 )
113
113
if [[ "${OPTION,,}" == "enable" ]]; then
114
114
echo "You chose to enable Wake-on-LAN."
115
115
echo "Requesting root privileges..."
@@ -127,23 +127,21 @@ toggle-wol:
127
127
echo "Removing udev rule to disable persistence..."
128
128
sudo rm -f "$CONFIG_FILE"
129
129
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
130
134
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 ."
133
137
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
144
142
sudo systemctl daemon-reload
145
143
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}"
147
145
else
148
146
echo "No changes were made."
149
147
fi
0 commit comments