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