Blame | Last modification | View Log | RSS feed
#!/bin/bash## yum-cron This shell script enables the automatic use of YUM## Author: Seth Vidal <skvidal@phy.duke.edu>## chkconfig: - 50 01## description: Enable daily run of yum, a program updater.# processname: yum-cron# config: /etc/yum/yum-daily.yum## source function library. /etc/rc.d/init.d/functionstest -f /etc/sysconfig/yum-cron && . /etc/sysconfig/yum-cronlockfile=/var/lock/subsys/yum-crontslock=/var/lock/yum-cron.lock/ts.lockyumcronpid=/var/lock/yum-cron.lock/pidfileRETVAL=0start() {echo -n $"Enabling nightly yum update: "touch "$lockfile" && success || failureRETVAL=$?echo}stop() {echo -n $"Disabling nightly yum update: "if [ -f "$yumcronpid" -a "$SERVICE_WAITS" = "yes" ]; thenyum_done=0if [ ! -f $tslock ]; then# No transaction yet in progress, just kill itkill `cat $yumcronpid > /dev/null 2>&1` > /dev/null 2>&1yum_done=1fiif [ $yum_done -eq 0 ]; thenecho -n $"Waiting for yum "if [ -z "$SERVICE_WAIT_TIME" ]; thenSERVICE_WAIT_TIME=300fistart=`date +%s`end=`expr $start + $SERVICE_WAIT_TIME`while [ `date +%s` -le $end ]dosleep 5if [ ! -f "$tslock" ]; thenyum_done=1breakfidoneif [ $yum_done -eq 1 ]; thenecho -n " ok "elseecho -n " failed "fififirm -f "$lockfile" && success || failureRETVAL=$?echo}restart() {stopstart}case "$1" instart)start;;stop)stop;;restart|force-reload)restart;;reload);;condrestart)[ -f "$lockfile" ] && restart;;status)if [ -f $lockfile ]; thenecho $"Nightly yum update is enabled."RETVAL=0elseecho $"Nightly yum update is disabled."RETVAL=3fi;;*)echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"exit 1esacexit $RETVAL