Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/bash
2
#
3
# yum-cron           This shell script enables the automatic use of YUM
4
#
5
# Author:       Seth Vidal <skvidal@phy.duke.edu>
6
#
7
# chkconfig:	- 50 01
8
#
9
# description:  Enable daily run of yum, a program updater.
10
# processname:  yum-cron
11
# config: /etc/yum/yum-daily.yum
12
#
13
 
14
# source function library
15
. /etc/rc.d/init.d/functions
16
 
17
test -f /etc/sysconfig/yum-cron && . /etc/sysconfig/yum-cron
18
 
19
lockfile=/var/lock/subsys/yum-cron
20
tslock=/var/lock/yum-cron.lock/ts.lock
21
yumcronpid=/var/lock/yum-cron.lock/pidfile
22
 
23
RETVAL=0
24
 
25
start() {
26
	echo -n $"Enabling nightly yum update: "
27
	touch "$lockfile" && success || failure
28
	RETVAL=$?
29
	echo
30
}
31
 
32
stop() {
33
	echo -n $"Disabling nightly yum update: "
34
	if [ -f "$yumcronpid" -a "$SERVICE_WAITS" = "yes" ]; then
35
	  yum_done=0
36
	  if [ ! -f $tslock ]; then
37
	    # No transaction yet in progress, just kill it
38
	    kill `cat $yumcronpid > /dev/null 2>&1` > /dev/null 2>&1
39
	    yum_done=1
40
	  fi
41
	  if [ $yum_done -eq 0 ]; then
42
	    echo -n $"Waiting for yum "
43
	    if [ -z "$SERVICE_WAIT_TIME" ]; then
44
	      SERVICE_WAIT_TIME=300
45
	    fi
46
	    start=`date +%s`
47
	    end=`expr $start + $SERVICE_WAIT_TIME`
48
	    while [ `date +%s` -le $end ]
49
	    do
50
	      sleep 5
51
	      if [ ! -f "$tslock" ]; then
52
		yum_done=1
53
	        break
54
	      fi
55
	    done
56
	    if [ $yum_done -eq 1 ]; then
57
	      echo -n " ok "
58
	    else
59
	      echo -n " failed "
60
	    fi
61
	  fi
62
	fi
63
	rm -f "$lockfile" && success || failure
64
	RETVAL=$?
65
	echo
66
}
67
 
68
restart() {
69
	stop
70
	start
71
}
72
 
73
case "$1" in
74
  start)
75
	start
76
	;;
77
  stop)
78
	stop
79
	;;
80
  restart|force-reload)
81
	restart
82
	;;
83
  reload)
84
	;;
85
  condrestart)
86
	[ -f "$lockfile" ] && restart
87
	;;
88
  status)
89
	if [ -f $lockfile ]; then
90
		echo $"Nightly yum update is enabled."
91
		RETVAL=0
92
	else
93
		echo $"Nightly yum update is disabled."
94
		RETVAL=3
95
	fi
96
	;;
97
  *)
98
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
99
	exit 1
100
esac
101
 
102
exit $RETVAL