--- /home/yuk/RPM.nut-2.2.2/SOURCES/upsdrv.init 2008-12-02 17:14:43 +0200 +++ upsdrv.init 2011-11-13 18:51:19 +0200 @@ -1,5 +1,5 @@ #!/bin/sh # -# chkconfig: 2345 87 13 +# chkconfig: 2345 51 89 # description: The UPS drivers # config: /etc/ups/ @@ -12,4 +12,5 @@ # Source service configuration. SourceIfNotEmpty /etc/sysconfig/upsd +SourceIfNotEmpty /etc/sysconfig/nut LOCKFILE=/var/lock/subsys/upsdrv @@ -19,6 +20,6 @@ get_drvlist() { - DRVLIST="$((find $CHROOTDIR/ -maxdepth 1 -name '*-*.pid' -type f | - sed -ne 's,'$CHROOTDIR'/\([^/-]\+\)-[^/-]\+\.pid$,/lib/nut/\1,p'; + DRVLIST="$((find $PIDDIR/ -maxdepth 1 -name '*-*.pid' -type f | + sed -ne 's,'$PIDDIR'/\([^/-]\+\)-[^/-]\+\.pid$,/lib/nut/\1,p'; upsdrvctl list 2>/dev/null |grep ^/ ) |sort -u)" @@ -37,14 +38,15 @@ stop() { - local f list rc=0 - get_drvlist - [ -n "$DRVLIST" ] || rc=3 - for f in $DRVLIST; do - msg_stopping $"${f##*/} UPS driver" - stop_daemon --expect-user upsdrv --no-announce -- "$f" - RETVAL=$? - [ "$RETVAL" = 0 ] || rc="$RETVAL" - done - RETVAL="$rc" + upsd_configured || return 0 + act="stop" + if [ -f /etc/killpower ]; then + UPS_SHUTDOWN=${UPS_SHUTDOWN:=9} + if [ $UPS_SHUTDOWN -eq 1 ]; then + act="shutdown" + fi + fi + + action "Stopping UPS drivers:" upsdrvctl $UPSDRV_OPTIONS $act + RETVAL=$? [ $RETVAL -eq 0 ] && rm -f "$LOCKFILE" return $RETVAL --- /home/yuk/RPM.nut-2.2.2/SOURCES/upsd.init 2008-12-02 17:14:43 +0200 +++ upsd.init 2011-11-13 18:51:19 +0200 @@ -1,5 +1,5 @@ #!/bin/sh # -# chkconfig: 2345 88 12 +# chkconfig: 2345 52 88 # description: The UPS information server # processname: upsd @@ -19,4 +19,5 @@ LOCKFILE=/var/lock/subsys/upsd RETVAL=0 +LABEL=upsd start() @@ -24,12 +25,12 @@ upsd_configured || return 0 - msg_starting $"UPS information" - if ! service upsdrv status >/dev/null 2>&1; then - msg_not_running $"UPS driver" - failure "upsd startup" - RETVAL=$? - echo - return $RETVAL - fi + #msg_starting $"UPS information" + #if ! service upsdrv status >/dev/null 2>&1; then + # msg_not_running $"UPS driver" + # failure "upsd startup" + # RETVAL=$? + # echo + # return $RETVAL + #fi start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd $UPSD_OPTIONS RETVAL=$? @@ -39,5 +40,24 @@ stop() { + + LABEL=upsd msg_stopping $"UPS information" + if [ -f /etc/killpower ]; then + + CONF=/etc/sysconfig/nut + test -f $CONF && . $CONF + UPS_SHUTDOWN=${UPS_SHUTDOWN:=9} + + if [ $UPS_SHUTDOWN -eq 2 ]; then + logger -t "$LABEL" "Initiated shutdown UPS as $DELAY_MODE." + UPSNAME=${UPSNAME:=ups} + UNAME=${UNAME:=upsmon} + PASSWORD=${PASSWORD:=mypass} + #logger -t "$LABEL" "upscmd -u $UNAME -p $PASSWORD ${UPS}@localhost shutdown.return" + upscmd -u $UNAME -p $PASSWORD ${UPSNAME}@localhost shutdown.return + logger -t "$LABEL" "upscmd shutdown.return exit status: $?" + sleep 1 + fi + fi stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd RETVAL=$? --- /home/yuk/RPM.nut-2.2.2/SOURCES/upsmon.init 2008-12-02 17:14:43 +0200 +++ upsmon.init 2011-11-13 18:51:19 +0200 @@ -1,5 +1,5 @@ #!/bin/sh # -# chkconfig: 2345 89 11 +# chkconfig: 2345 53 87 # description: The UPS monitor and shutdown controller # processname: upsmon