Answer the question
In order to leave comments, you need to log in
How to write a script to turn on a PC via WoL?
Prerequisites: A computer (Linux) is connected to an Ippon UPS and configured to shut down gracefully in the event of a power outage (nut).
When power is restored, it must automatically turn on itself, and for this to happen, the UPS must turn off completely some time after a power outage and supply power to the PC, which is configured in the BIOS to automatically turn on when power is applied.
And at this stage, problems arose, the essence of which is that the UPS simply does not wake up with this setting, i.e. you can’t let the UPS go to bed, otherwise you will have to turn everything on manually.
All available manuals for nut smoked, incl. by service commands, but does not work.
There was an idea to make something like a network watchdog from an existing old router flashed with OpenWRT.
The idea is that the router periodically (once a minute, for example) pings the PC (which has WoL enabled) and if there is no ping, then the PC is turned off, and then the router sends a magic packet to the PC's MAC address via etherwake, for example, once every minute and continues to ping.
Ping appeared - we stop sending magic, ping disappeared - we send magic. Actually, the question is how to implement a script for this task?
Answer the question
In order to leave comments, you need to log in
wakeup.sh
#!/usr/bin/sh
IP=$1
MAC=$2
dT=$3
while sleep $dT; do
until $(fping -r 1 -q $IP); do
etherwake $MAC
done
done
./wakeup.sh 192.168.1.10 ff:ff:ff:ff:ff:ff 60
In general, it would be great to have a specific manual for solving the described problem. After all, it occurs in all normal people, but I did not come across sensible solutions.
In most cases, NUT only gets in the way.
I do this - I turn off all automation in NUT, the OS does not shutdown. If the battery at the UPS is still discharged, then the server is turned off by power. This at least guarantees its automatic inclusion after the appearance of power (if the BIOS is correctly configured). The downside is obvious - incorrect shutdown of the OS, fsck, raid rebuild and other delights.
Possible options:
* Shutdown OS using NUT after a specified time after a power failure.
There is no guarantee that the battery will last for a given time (due to battery degradation).
Restoring power during an OS shutdown. We get a turned off server.
* Shutdown OS using NUT when it reaches the threshold for the rest of the UPS charge.
All cheap UPSs lie, especially over time, all mine lie heavily.
Again, the problem is with restoring power during shutdown.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question