aredn/files/usr/local/bin/olsrd-watchdog

29 lines
470 B
Bash
Executable File

#!/bin/sh
# wait for the watchdog file to appear before starting
while [ ! -f "/tmp/olsrd.watchdog" ]
do
sleep 15
done
while true
do
if [ -f "/tmp/olsrd.watchdog" ]
then
rm -f "/tmp/olsrd.watchdog"
else
uptime=`cat /proc/uptime | cut -d' ' -f1`
date=`date`
echo "$uptime $date" >> /tmp/olsrd.log
/etc/init.d/olsrd restart
fi
# With interval of 5 seconds this gives ~3 chances
# for a file write before next loop.
sleep 15
done