Apcupsd script Power on LAN to server

I would like to restart my server automatically after the mains voltage returns. → Power on LAN

I am looking for a script that I can integrate into the existing email script from apcupsd.
(Power is back. UPS running on mains.)

Thank you.

Use the /etc/apcupsd/offbattery script and add a WOL command into it.

Use the IPFire WOL command.

/usr/sbin/etherwake -i $I $M

where $I should be the interface - green0 if on the green lan and $M is the mac address of the server computer.


Thank you that worked.

Is there also a possibility to shut down the server via LAN in the same way?

Or do I have to tinker with something?

You can run apcupsd on the server and make the UPSCABLE ether and UPSTYPE net with DEVICE as hostname (or IP address):port. A common port used is 3551 which also needs to be set in the NETSERVER section - see below.

The above makes that server a slave in terms of apcupsd to the one attached to the UPS (IPFire I believe in your case). Then when the UPS battery gets to the trigger point for shutting down IPFire it will also shutdown your server. You can have different settings for battery level, delay time etc on the two apcupsd.conf files so that the server is shutdown before IPFire is, so that it is always last.

You will need to readup on the NETSERVER section of apcupsd.conf as this needs to be changed to on for slaving two or more machines together plus some other parameters set accordingly for your network.

The above is how I have got it set up on my system.