#!/bin/bash
#	dmonitor
#	auto update of repeater_mon.html & repeater_conn.txt

ymd=`date +"%Y%m%d%H%M%S" -r /var/tmp/access.log`

systemctl stop auto_repmon_light

while :
do
repeater_mon 
if [ -f /var/tmp/access.log ]; then
ymd_new=`date +"%Y%m%d%H%M%S" -r /var/tmp/access.log`
if [ $ymd != $ymd_new ]; then
cp /dev/null /var/tmp/access.log
chown www-data:www-data /var/tmp/access.log
ymd=`date +"%Y%m%d%H%M%S" -r /var/tmp/access.log`
fi
fi

if [ ! -f /var/tmp/connected_table.html ]; then
/bin/cp -n /var/www/html/connected_table.org /var/tmp/connected_table.html
fi
if [ ! -f /var/tmp/repeater_active.html ]; then
/bin/cp -n /var/www/html/repeater_active.org /var/tmp/repeater_active.html
fi
if [ ! -f /var/tmp/repeater_mon.html ]; then
/bin/cp -n /var/www/html/repeater_mon.org /var/tmp/repeater_mon.html
fi
if [ ! -f /var/tmp/repeater_scan.html ]; then
/bin/cp -n /var/www/html/repeater_scan.org /var/tmp/repeater_scan.html
fi
if [ ! -f /var/tmp/error_msg.html ]; then
/bin/cp -n /var/www/html/error_msg.html.save /var/tmp/error_msg.html
fi
if [ ! -f /var/tmp/short_msg.html ]; then
/bin/cp -n /var/www/html/short_msg.html.save /var/tmp/short_msg.html
fi

sleep 5 
done
