Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 2cb2d9a8500ea21b82e5d7b831a996fc > files > 2

bpowerd-3.0b1-4mdk.src.rpm

#!/bin/sh
#
# bpowerd
#
# chkconfig: 2345 32 68
# description: Starts/stops the daemon to monitor a Best UPS
#

# Source function library.
[ -x /usr/sbin/bpowerd ] || exit 0

# if /etc/sysconfig/power does not exist define UPS_DEVICE here
if [ -f /etc/sysconfig/power ]; then
    . /etc/sysconfig/power
else
    UPS_DEVICE=/dev/ups
fi

. /etc/rc.d/init.d/functions
[ ! -z "$UPS_DEVICE" ] || exit 0
# See how we were called.

if [ "$(id -u)" != "0" ]
then
  echo "You must be root to start, stop or restart bpowerd."
  exit 1
fi

case "$1" in
  start)
        # Start daemons.
        echo -n "Starting UPS monitoring system: "
        daemon /usr/sbin/bpowerd "$UPS_DEVICE"
	echo ""
	touch /var/lock/subsys/bpowerd
        ;;
  stop)
        # Stop daemons.
	echo -n "Shutting down bpowerd: "
		
	if [ "`/sbin/pidof bpowerd`" != "" ]; then
	    kill -INT `/sbin/pidof bpowerd`
	    while [ "`/sbin/pidof bpowerd`" != "" ]; do
		sleep 1;
	    done
	    echo "bpowerd"
	else
	    echo ""
	fi
	
	rm -f /var/lock/subsys/bpowerd
	;;
  restart)
	# restart daemon
	echo -n "Stop bpowerd: "
	kill -TERM `/sbin/pidof bpowerd`
	echo "bpowerd"
	daemon /usr/sbin/bpowerd "$UPS_DEVICE"
	touch /var/lock/subsys/bpowerd
	;;
    *)
          echo "Usage: bpowerd.init {start|stop|restart}"
          exit 1
	  ;;
  esac
exit 0