Chapter 34. check_UFR_is_there.sh
#!/bin/sh
# make sure UFR is installed, and install it if it isn't
# first check for the scripts, and install if necessary
if [ ! -f /sysadmin/clean_ufr_logs.sh ]
then
cp /repo/scripts/clean_ufr_logs.sh /sysadmin/clean_ufr_logs.sh
fi
if [ ! -f /sysadmin/ufr.sh ]
then
cp /repo/scripts/ufr.sh /sysadmin/ufr.sh
fi
# second, make sure crontab entry exists, and create it if necessary
CRONTAB=/var/spool/cron/root
if [ ! -f $CRONTAB ]
then
echo "Can't find root crontab at ${CRONTAB}, aborting"
exit 1
fi
crontab -l -u root | grep '/sysadmin/clean_ufr_logs.sh' >/dev/null
if [ $? -ne 0 ]
then
echo '0 3 * * * /sysadmin/clean_ufr_logs.sh' >> $CRONTAB
/etc/init.d/crond reload >/dev/null 2>/dev/null
sleep 1
fi
crontab -l -u root | grep '/sysadmin/ufr.sh' >/dev/null
if [ $? -ne 0 ]
then
echo '0-59/5 * * * * /sysadmin/ufr.sh' >> $CRONTAB
/etc/init.d/crond reload >/dev/null 2>/dev/null
sleep 1
fi