#!/bin/bash
#
# chkconfig: 2345 30 90
# description: PowerSoft Plus is EVER UPS monitoring software
# processname: powersoftplus
# config: /etc/psplus/*

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
export PATH

# Source function library.
. /etc/rc.d/init.d/functions

binpath="@prefix@/bin"

[ -f ${binpath}/powersoftplus ] || exit 0

case $1 in
    start)
	echo
        exec ${binpath}/powersoftplus -q
        runtest = `${binpath}/powersoftplus -p|grep -i UPS STATE`
        sleep 1
        if [ -n "$runtest" ]; then
	    echo_success
	else
	    echo_failure
	fi
	;;
    stop)
        exec ${binpath}/powersoftplus -t
        sleep 1
        echo_success
	;;
    params)
	exec ${binpath}/powersoftplus -p
	;;
    updatecfg)
        exec ${binpath}/powersoftplus -u
	;;
    *)
	echo "Usage syntax: $0 [start/stop/params/updatecfg]"
	;;
esac

exit 0
