Ping and Repower

Using our LieberLieber PiSaint Solution ( enables us to develop such a solution to re-power instable Internet Access Routers of some providers.

1.) Ping (it is and should be alive 24/7)

2.) on error: turn off power of power sockets (default is on, off is set with high)

3.) wait 10 secs

4.) turn on power of power sockets again

5.) wait 10 mins

6.) goto 1.)

Here the bash script (developed by our junior, junior engineers)

gpio -g mode 21 out
gpio -g write 21 0
while true
ping -c 1 > ping.txt
a=$(grep -r  -i 'errors' ping.txt)
if [ ! -z '$a' ];
gpio -g write 21 1
sleep 10
gpio -g write 21 0
sleep 6000

Of course there is an entry in /etc/rc.local to start this script.