#! /bin/bash
### BEGIN INIT INFO
# Provides:          startupgrade 
# Required-Start:    $all 
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Network Injector Appliance Autoupgrade 
# Description:       Run startupgrade
### END INIT INFO

NAME="Network Injector Appliance Autoupgrade"

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

VERBOSE="yes"

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

# Function that starts the daemon/service
do_start()
{
        # Return
        #   0 if daemon has been started

	/etc/init.d/autoupgrade &

	return 0
}

# Function that stops the daemon/service
do_stop()
{
        # Return
        #   0 if daemon has been stopped

	killall -9 autoupgrade 2> /dev/null

        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME"
        do_start
        case "$?" in
                0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME"
        do_stop
        case "$?" in
                0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop}" >&2
        exit 3
        ;;
esac
