#!/bin/sh # # chkconfig: 2345 30 90 # # 2002-08-26 Arnaud de Lorbeau <adelorbeau@mandrakesoft.com> # Error messages about "no configuration done" are moved to syslog and not to the screen. # Add a reload entry and remove old style commands # 2002-02-07 Nigel Metheringham <Nigel.Metheringham@InTechnology.co.uk> # made ups.conf pre-eminant, added new upsdrvctl functions, targeted for RH7.2, should # work OK on RH 6.x, 7.x # 2001-10-24 Peter Bieringer <pb@bieringer.de> # enhancements for new style drivers and controls, tested on a RHL 7.1.93 system # # description: NUT upsd and its drivers directly monitor a ups and \ # make information from it available to other programs # processname: upsd # config: @sysconfdir@/upsd.conf # config: @sysconfdir@/ups.conf PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH # Source function library. . /etc/rc.d/init.d/functions # POWERDOWNFLAG *must* match that in upsmon.conf DRIVERPATH=/sbin POWERDOWNFLAG=/etc/killpower UPSDCONF=/etc/ups/upsd.conf UPSCONF=/etc/ups/ups.conf # if there is no config file, bail out [ -f $UPSDCONF ] || (logger -i -p local1.err -t upsd "NUT No UPS drivers were configured" && exit 4) if [ $? == 4 ]; then exit 0; fi runcmd() { gprintf "%s " "$1" shift if [ "$BOOTUP" = "color" ]; then $* && echo_success || echo_failure else $* fi echo } # See how we are called. case "$1" in start) if [ -f $UPSCONF ]; then TESTUP=`grep -v "#" $UPSCONF` if [ -z "$TESTUP" ]; then logger -i -p local1.err -t upsd "NUT No UPS drivers were configured" && exit 0; fi gprintf "NUT Starting UPS model drivers: " daemon upsdrvctl start echo if [ $? -eq 0 ]; then gprintf "NUT Starting UPS daemon: " daemon upsd echo touch /var/lock/subsys/upsd else failure "NUT No UPS drivers were configured" echo fi else failure "NUT No UPS drivers were configured" echo fi ;; stop) gprintf "NUT Stopping UPS daemon: " killproc upsd echo action "NUT Stopping UPS model drivers" upsdrvctl stop rm -f /var/lock/subsys/upsd ;; powerdown) runcmd "NUT powerdown of attached UPS(es)" upsdrvctl shutdown ;; restart) $0 stop $0 start ;; reload) if [ -f /var/lock/subsys/upsd ]; then gprintf "NUT UPS daemon Reread configurations: " daemon upsd -c reload echo fi ;; status) action "NUT: checking UPS model drivers" upsdrvctl status status upsd ;; *) gprintf "Usage: upsd {start|stop|powerdown|restart|reload|status}\n" exit 1 esac