#!/bin/bash
#
# yum           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
#

# source function library
. /etc/rc.d/init.d/functions

lockfile=/var/lock/subsys/yum

start() {
	echo -n $"Enabling nightly yum update: "
	touch $lockfile && success || failure
	retval=$?
	echo
	return $retval
}

stop() {
	echo -n $"Disabling nightly yum update: "
	rm -f $lockfile && success || failure
	retval=$?
	echo
	return $retval
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop) 
	stop
	;;
  restart|force-reload)
	restart
	;;
  reload)
	;;
  condrestart)
	[ ! -f $lockfile ] || restart
	;;
  status)
	if [ -f $lockfile ]; then
		echo $"Nightly yum update is enabled."
		exit 0
	else
		echo $"Nightly yum update is disabled."
		exit 3
	fi
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
	exit 1
esac
