Because of instability found in the ATCOM IP-01, the follwing two rountines are developed for taking care of any failure found and regularly reboot the system to keep the IP-01 in fresh condition during the day.
The first routine IsAsteriskAlive.sh is repsonsbile for any Asterisk failure found. The codes was originally developed by ATCOM engineers and modified by me by replace the asterisk restart to reboot.
The second routine RebootTime.sh is used to boot IP-01 every morning at 4:00AM in order to make the whole system fresh from any accumulated problems after a number of days running.
/persistent/etc/IsAsteriskAlive.sh
#!/bin/sh
while [ 1 ]
do
IsAlive=`pidof asterisk`
if [[ -z "$IsAlive" ]] ; then
echo "Asterisk die at `date`" >> /persistent/DieLog
#/etc/init.d/asterisk start # disable by YH Fung on 31 July 2010
reboot
fi
sleep 60
done
複製代碼
/persistent/etc/RebootTime.sh
#!/bin/sh
# TIME is given by the following script is GMT instead of the local time.
# For Hong Kong, if you want the IP-01 to reboot at 04:00, you have set the
# GMT time 20:00. The following is a list of table for easy reference
#
# HK Time GMT
# 03:00 19:00
# 04:00 20:00
while [ 1 ]
do
TIME=`date | cut -c 12-16`
if [ "$TIME" == "20:00" ] ; then
echo "Asterisk is rebooted at `date`" >> /persistent/DieLog
reboot
fi
sleep 50
done
複製代碼
The following script may be deleted later if necessary.
echo "Asterisk is rebooted at `date`" >> /persistent/DieLog
複製代碼
The following scripts will run the above two scripts automatically when system reboot.