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

48 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
<<'LICENSE'
Part of BBHN Mesh -- Used for creating Amateur Radio friendly mesh networks
Copyright (C) 2015 Conrad Lara
See Contributors file for additional contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
LICENSE
# 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