[Nut-upsuser] Shutdown problem with Geek Squad GS1285U

Gary Redden
Thu, 08 Feb 2007 03:30:28 -0000

I am still not able to get the UPS to shutdown. Here is a list of rc0.d
and the file I created to shutdown the UPS after umountroot  mounts the
filesystem read-only and before halt (halt seems to be a no op here. No
code under the start case).

gary@redden-p700-610:~$ cd /etc/rc0.d
gary@redden-p700-610:/etc/rc0.d$ ls -l
total 4
lrwxrwxrwx 1 root root  13 2007-01-26 11:13 K01gdm -> ../init.d/gdm
lrwxrwxrwx 1 root root  17 2007-01-26 11:13 K01usplash -> ../init.d/usplash
lrwxrwxrwx 1 root root  17 2007-01-26 11:58 K19camserv -> ../init.d/camserv
lrwxrwxrwx 1 root root  15 2007-01-26 11:13 K19hplip -> ../init.d/hplip
lrwxrwxrwx 1 root root  15 2007-01-28 17:43 K19samba -> ../init.d/samba
lrwxrwxrwx 1 root root  14 2007-01-26 11:13 K20dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root  13 2007-01-26 11:57 K20nut -> ../init.d/nut
lrwxrwxrwx 1 root root  21 2007-02-01 13:05 K20ups-monitor ->
../init.d/ups-monitor
lrwxrwxrwx 1 root root  20 2007-01-26 11:13 K25hwclock.sh ->
../init.d/hwclock.sh
lrwxrwxrwx 1 root root  20 2007-01-26 11:13 K50alsa-utils ->
../init.d/alsa-utils
lrwxrwxrwx 1 root root  17 2007-01-26 11:52 K91apache2 -> ../init.d/apache2
-rw-r--r-- 1 root root 355 2006-10-06 07:34 README
lrwxrwxrwx 1 root root  41 2007-01-26 11:13
S01linux-restricted-modules-common ->
../init.d/linux-restricted-modules-common
lrwxrwxrwx 1 root root  22 2007-01-26 11:13 S15wpa-ifupdown ->
../init.d/wpa-ifupdown
lrwxrwxrwx 1 root root  18 2007-01-26 11:13 S20sendsigs ->
../init.d/sendsigs
lrwxrwxrwx 1 root root  17 2007-01-26 11:13 S30urandom -> ../init.d/urandom
lrwxrwxrwx 1 root root  22 2007-01-26 11:13 S31umountnfs.sh ->
../init.d/umountnfs.sh
lrwxrwxrwx 1 root root  18 2007-01-26 11:13 S40umountfs ->
../init.d/umountfs
lrwxrwxrwx 1 root root  20 2007-01-26 11:13 S60umountroot ->
../init.d/umountroot
lrwxrwxrwx 1 root root  22 2007-02-07 15:29 S89ups-shutdown ->
../init.d/ups-shutdown
lrwxrwxrwx 1 root root  14 2007-01-26 11:13 S90halt -> ../init.d/halt
gary@redden-p700-610:/etc/rc0.d$ cd /etc/init.d
gary@redden-p700-610:/etc/init.d$ cat ups-shutdown
#! /bin/sh
#
# nut - Script to Shutdown UPS if line power is lost & low battery

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=ups-shutdown
DESC="UPS Shutdown"
DEFAULT=/etc/default/nut

[ -f $DEFAULT ] || exit 0
. $DEFAULT

upsdrvctl=/usr/local/ups/bin/upsdrvctl
log=">/dev/null 2>/dev/null"

case "$1" in

  start)
    echo -n "Starting $DESC:"
    flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p'
usr/local/ups/etc/upsmon.conf`
    wait_delay=`sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p'
/etc/default/nut`
    if [ -f "$flag" ] ; then
      if [ $upsdrvctl shutdown >/dev/null ] ; then
        echo -n "Waiting for UPS to cut the power"
        sleep 5
      else
        echo "Shutdown failed."
        echo -n "Waiting for UPS batteries to run down"
        sleep 10
      fi
      if [ "$wait_delay" ] ; then
        echo " (will reboot after $wait_delay) ..."
        sleep "$wait_delay"
        /etc/init.d/reboot
      fi
    else
      echo "Power down flag is not set (UPS shutdown not needed)"
    fi

    ;;

  stop)
    ;;

  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop}" >&2
    exit 1
    ;;

esac

exit 0
gary@redden-p700-610:/etc/init.d$