#!/bin/sh
# 
# Copyright 1999 American Power Conversion, All Rights Reserved
#
# Revision History:
#  msamson  01Apr99 For Linux, we have to remove upsoff.cmd, because we cannot 
#                   remove this file once all filesystems have been unmounted
#                   in our shutdown script. 
#  msamson  04Oct99 Incorporated standard init fixes from Redhat 
#                   (pjones@redhat.com)
#
# chkconfig: 2345 98 92
# description: Uninterruptable Power Supply Monitoring Daemon
#
#

if [ -f /etc/redhat-release ]; then
  . /etc/rc.d/init.d/functions
fi

INSTALL_PATH="GSUB_INSTALL_PATH"

if [ -r /upsoff.cmd ]
then
    rm -f /upsoff.cmd
fi

if [ -f /etc/redhat-release ]; then
	RETVAL=$? 
fi

case "$1" in
start)
	cd $INSTALL_PATH
	./upsd GSUB_START_FLAGS  2>/dev/null
	if [ -f /etc/redhat-release ]; then
		RETVAL=$?
	  	action "PowerChute Plus for Unix, v4.5.2 (glibc): Copyright (c) 1999, American Power Conversion" /bin/true
	  	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/upsd 
	else 
	  	echo
	  	echo "PowerChute Plus for Unix, v4.5.2 (glibc): Copyright (c) 1999, American Power Conversion "
	  	echo
	fi
	;;
stop)
	if [ -f /etc/redhat-release ]; then
	  	echo -n "Shutting down upsd: "
	  	killproc _upsd
	  	rm -f /var/lock/subsys/upsd
		echo
	fi
	;;
reload|restart)
	if [ -f /etc/redhat-release ]; then
		if [ ! -f /var/lock/subsys/upsd ]; then
			echo "upsd not running"
			exit 1
		fi
		$0 stop
		$0 start
	fi
	;;
status)
	if [ -f /etc/redhat-release ]; then
		status _upsd
	fi
	;;
*)
	if [ -f /etc/redhat-release ]; then
		echo "*** Usage: upsd {start|stop|status|restart}"
		exit 1
	else 
		echo "Usage upsd [start|stop]"
	fi
	;;
esac

if [ -f /etc/redhat-release ]; then
	exit $RETVAL
fi




















