#!/bin/sh

### BEGIN INIT INFO
# Provides:          uptrack
# Required-Start:    $local_fs
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Applies Uptrack updates at boot-time.
# Description:       Applies Uptrack updates at boot-time.
# X-Start-Before:    $network
### END INIT INFO

UPTRACK="/usr/sbin/uptrack-upgrade"
UPTRACK_ARGS="--init"

[ -x "$UPTRACK" ] || exit 0

# Define LSB log_* functions.
. /lib/lsb/init-functions

case "$1" in
  start)
	/usr/lib/uptrack/ksplice-cleanup
	if "$UPTRACK" --check-init; then
		log_begin_msg "Applying Ksplice Uptrack updates..."
		"$UPTRACK" $UPTRACK_ARGS
		log_end_msg $?
	fi
	;;
  stop|restart|force-reload)
	echo "Error: There is no Uptrack daemon to $1:"
	echo "  You never need to invoke the Uptrack init script manually."
	echo "  This init script is only used to reinstall the Ksplice updates that were"
	echo "  installed prior to the machine shutting down during the boot process."
	exit 1
	;;
  *)
    echo "Usage: /etc/init.d/uptrack {start|stop|restart|force-reload}"
    exit 1
	;;
esac
exit 0
