#!/bin/bash
# chkconfig: 5 32 10
# description: update notifier Daemon
# processname: simple update notifier
### BEGIN INIT INFO
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 5
# Default-Stop:	0 6
# Short-Description: Start update notifier on boot
# Description: This script starts the  update notifier Daemon
### END INIT INFO

# Source function library.

NAME=update-notifier
RUN_DIR=/usr/share/simple-notifier/scripts/update-check

. /lib/lsb/init-functions

ret=0

case $1 in 
    start)
	gprintf "Starting update notifier: "
	$RUN_DIR &
	success "Update notifier startup"
	ret=$?
	echo
	if [ $ret = 0 ]; then
	    touch /var/lock/subsys/$NAME
	fi
	;;

    stop)
	gprintf "Stopping update notifier:"
	killproc $NAME
	ret=$?
	if [ $ret = 0 ]; then
	    success "Update notifier shutdown"
	    rm -f /var/lock/subsys/$NAME
	else
	    failure "Update notifier shutdown"
	fi
	echo
	;;

    status)
	status $NAME
	;;

    reload)
	;;

    restart)
	$0 stop
	sleep 5
	$0 start
	ret=$?
	;;
    *)
	gprintf "Usage: %s\n" "$(basename $0) {start|stop|restart|status}"
	exit 0
	;;
esac

exit $ret

