#!/bin/bash
#
# yum           This shell script enables the automatic use of YUM
#
# Author:       Seth Vidal 
#
# chkconfig:	- 50 01
#
# description:  Enable daily run of yum, a program updater.
# processname:  yum
# config: /etc/yum.conf
#

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

lockfile=/var/lock/subsys/yum

RETVAL=0

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

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

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."
		RETVAL=0
	else
		echo $"Nightly yum update is disabled."
		RETVAL=3
	fi
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
	exit 1
esac

exit $RETVAL