[Nut-upsuser] Shutdown problem with Geek Squad GS1285U

Peter Selinger selinger at mathstat.dal.ca
Thu Feb 8 18:36:25 CET 2007


I see. Sorry for that; my halt script looks very different. However, I
don't think it's a no-op; at least not if it's called with parameter
"stop". 

To test the shutdown script, you should of course not wait for the
battery to run down. You should use "upsmon -c fsd". 

-- Peter

Gary Redden wrote:
> 
> Peter:
> I created S89ups-shutdown because the halt script is a no-op see the 
> attached file. Also on the I went to the Ubuntu site to look up the 
> functions of the other scripts in rc0.d. It said not to mess with halt 
> and this was an easy way to remove the change if I had to. I am going to 
> make the correction you suggested and test now. It takes 2 hours for the 
> battery to run down so testing is not easy. I tried to set the low 
> battery to a higher number but the UPS only accepts 600 seconds as the 
> highest time.
> gary at redden-p700-610:~$ cat /etc/init.d/halt
> #! /bin/sh
> ### BEGIN INIT INFO
> # Provides:          halt
> # Required-Start:    umountroot
> # Required-Stop:
> # Should-Start:      lvm raid2
> # Should-Stop:
> # Default-Start:     0
> # Default-Stop:
> # Short-Description: Execute the halt command.
> # Description:
> ### END INIT INFO
> 
> PATH=/usr/sbin:/usr/bin:/sbin:/bin
> [ -f /etc/default/halt ] && . /etc/default/halt
> 
> . /lib/lsb/init-functions
> 
> do_stop () {
>         if [ "$INIT_HALT" = "" ]
>         then
>                 case "$HALT" in
>                   [Pp]*)
>                         INIT_HALT=POWEROFF
>                         ;;
>                   [Hh]*)
>                         INIT_HALT=HALT
>                         ;;
>                   *)
>                         INIT_HALT=POWEROFF
>                         ;;
>                 esac
>         fi
> 
>         # See if we need to cut the power.
>         if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
>         then
>                 /etc/init.d/ups-monitor poweroff
>         fi
> 
>         # Don't shut down drives if we're using RAID.
>         hddown="-h"
>         if grep -qs '^md.*active' /proc/mdstat
>         then
>                 hddown=""
>         fi
> 
>         # If INIT_HALT=HALT don't poweroff.
>         poweroff="-p"
>         if [ "$INIT_HALT" = "HALT" ]
>         then
>                 poweroff=""
>         fi
> 
>         log_action_msg "Will now halt"
>         sleep 1
>         halt -d -f -i $poweroff $hddown
> }
> 
> case "$1" in
>   start)
>         # No-op
>         ;;
>   restart|reload|force-reload)
>         echo "Error: argument '$1' not supported" >&2
>         exit 3
>         ;;
>   stop)
>         do_stop
>         ;;
>   *)
>         echo "Usage: $0 start|stop" >&2
>         exit 3
>         ;;
> esac
> 
> :
> gary at redden-p700-610:~$
> 
> 
> Peter Selinger wrote:
> > I am not sure why you created a file S89ups-shutdown. You were
> > supposed to edit init.d/halt. There is usually more stuff in
> > init.d/halt besides shutting off the power, and you really want to
> > make sure that that stuff is called before you turn off the UPS (which
> > turns off your computer). 
> >
> > The reason it's not working is probably that you forgot a "/" in front
> > of /usr/local/ups/etc/upsmon.conf. You should also make sure that is
> > the correct location of your upsmon.conf.
> >
> > -- Peter
> >
> > Gary Redden wrote:
> >   
> >> 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 at redden-p700-610:~$ cd /etc/rc0.d
> >> gary at 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 at redden-p700-610:/etc/rc0.d$ cd /etc/init.d
> >> gary at 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 at redden-p700-610:/etc/init.d$
> >>
> >>
> >> _______________________________________________
> >> Nut-upsuser mailing list
> >> Nut-upsuser at lists.alioth.debian.org
> >> http://lists.alioth.debian.org/mailman/listinfo/nut-upsuser
> >>
> >>     
> >
> >
> >   
> 
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/nut-upsuser
> 




More information about the Nut-upsuser mailing list