I use APC remote control power distribution units. They give me eight power ports, controllable remotely via my network; very nice. It means that I can be on the other side of the world, and reboot my computers.
I used to have three DSL lines, used for backup across the internet, because they were cheaper than my old 2mbit leased line. When I moved to a 100 mbit connection, I didn't really need them. But I kept one, because A) it gives me at least some connectivity if the 100 mbit line goes down (which it has, they called it routine maintenance, but they didn't warn me in advance, so I claimed compensation, which I got) and it also means that I have a way of accessing my network from "outside".
The APC PDU was still there, now controlling only one DSL router. Which is a waste, I could find a use for that elsewhere. So, I thought, let's make a remote rebooter from parts in my parts box.
I used a Raspberry Pi, of course, version 1. I also had a little relay board, they cost £1 on eBay.
The DSL is powered by a plug-in power supply which claims to give 12 volts; it actually gave 15 volts. Too rich for the Pi, I already fried one that way! So I used a step-down converter (eBay, £1.33) to get it down to the needed 5 volts.
I connected pin 2 of the Pi to give the relay its 5 volts, and pin 6 for the ground. Pin 12 is GPIO18, and that was the pin that would switch the relay. So the 15 volt PSU supplied the Pi after going through the converter, and also supplied the DSL router, after going through the relay.
The software to control this was pretty simple. First, run only once after boot-up, to set up the Pi gpio pin.
# put the gpio pin 18 (physical 12) under control of the kernel
echo "18" > /sys/class/gpio/export
# make pin 18 an output pin
echo "out" > /sys/class/gpio/gpio18/direction
Then, to switch on, I do "gpio -g write 18 0" and to switch off, I do "gpio -g write 18 1".
Instead of having to log in to do this, I implemented a little cgi, so that I can access it as a web page and click the on or off button.