#!/bin/bash

# Copyright 2003-2004 Hewlett-Packard
#
# See "man chkconfig" for information on next two lines (Red Hat only)
# chkconfig: 2345 91 1
# description: HP Insight Management Agents
#
#
# Following lines are in conformance with LSB 1.2 spec (ie, SuSE "insserv")
### BEGIN INIT INFO
# Provides:            hpima
# Required-Start:      snmp
# Required-Stop:
# Default-Start:       2 3 4 5
# Default-Stop:        0 1 6
# Description:         HP Insight Management Agents
### END INIT INFO

CONF=/etc/opt/hp/hpima.conf
[ ! -e $CONF ] && echo "Missing $CONF: package is corrupt" >&2 && exit 1
. $CONF

RETVAL=0
ACTION=${1-""}	# Provide a default if the variable is unset
shift
ADDARGS=$*	# only these; if omitted, start them all
set -u

# See how we were called.
case "$ACTION" in
  start)
	$HELPER start $ADDARGS
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	;;
  stop)
	$HELPER stop $ADDARGS 
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
	;;
  restart)
	$HELPER stop $ADDARGS
	$HELPER start $ADDARGS
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	;;
  status|configure|reconfigure|unconfigure|sample)
	$HELPER $ACTION $ADDARGS
	RETVAL=$?
	;;
  *)
	# HELPER has some args to assist deployment, they don't belong here
	echo "Usage: `basename $0` { start | stop | restart | status | configure | reconfigure | unconfigure | sample}"
	RETVAL=1
esac

exit $RETVAL
