#!/bin/sh
reboottime=500
if [ ! -e /etc/rc.d/rc.local ]; then
touch /etc/rc.d/after.local
chmod +x /etc/rc.d/after.local
rebootfile=after.local
else
rebootfile=rc.local
fi
if [ ! -e /usr/logreboot.log ]; then
echo "`pwd`/linux_reboot.sh" >> /etc/rc.d/$rebootfile
chmod +x /etc/rc.d/$rebootfile
fi
date >> /usr/logreboot.log
wc -l /usr/logreboot.log >/usr/logbak.log
if grep "$reboottime" /usr/logbak.log > /dev/null 2>&1
then
echo "Reboot for $reboottime times sucessfully" >> /usr/logreboot.log
rm /usr/logbak.log
mv -f /usr/logreboot.log /usr/reboot`date +%m%d%H%M`.log
grep -v "linux_reboot" /etc/rc.d/$rebootfile > /etc/rc.d/rc.local.bak
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/$rebootfile
else
reboot
rm /usr/logbak.log
fi
exit 0