[Nut-upsuser] Shutdown problem with Geek Squad GS1285U
Gary Redden
redden at skybest.com
Tue Feb 6 19:41:01 CET 2007
See the poweroff section of the script. My question is:
"Since I do not have much knowledge on how the Linux system boots and
shutdown I have spent the last several days searching for how the scrips
/etc/init.d are supposed to work but every thing I have found is a
little different than what I find on my Ubuntu system. Does this script
ever get called with poweroff?"
Peter Selinger wrote:
> For NUT to switch off your UPS at the end of the shutdown sequence,
> you have to edit your shutdown scripts.
>
> See INSTALL, "Configuring shutdowns for low battery events", item 11
> "Edit your shutdown scripts: add upsdrvctl shutdown".
>
> -- Peter
>
> Gary Redden wrote:
>
>> Nut will monitor the ups and shutdown Linux when the ups goes to low
>> battery as it should. But the UPS is not shut down so the system will
>> restart when the power is restored. If I switch the UPS off , restore
>> power and switch the UPS on the system will restart. I have not been
>> able to get nut to switch the UPS off after it brings the system down. I
>> can get the UPS to switch off with upscmd load.off. So the UPS can be
>> controlled. Here is my SHUTDOWNCMD:
>> SHUTDOWNCMD "/sbin/shutdown now -P"
>> I also tried:
>> SHUTDOWNCMD "/sbin/shutdown now -h"
>> I found this script in /etc/init.d/nut and changed the paths to upsd and
>> upsmon and used it.
>> #! /bin/sh
>> #
>> # nut - Script to start and stop Network UPS Tools daemons
>>
>> PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
>> NAME=nut
>> DESC="Network UPS Tools"
>> DEFAULT=/etc/default/nut
>>
>> [ -f $DEFAULT ] || exit 0
>> . $DEFAULT
>>
>> pid_dir=/var/run/nut
>> upsmon_pid=${pid_dir}/upsmon.pid
>> upsd_pid=${pid_dir}/upsd.pid
>> upsd=/usr/local/ups/sbin/upsd
>> upsmon=/usr/local/ups/sbin/upsmon
>> upsdrvctl=/usr/local/ups/bin/upsdrvctl
>> log=">/dev/null 2>/dev/null"
>>
>> # Check if /var/run/nut exists and has the correct perms
>> check_var_directory() {
>> [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \
>> && chown root:nut ${pid_dir} \
>> && chmod 770 ${pid_dir}
>> }
>>
>> start_stop_server () {
>> case "$START_UPSD" in
>> y|Y|yes|YES|Yes)
>> case "$1" in
>> start)
>> ! $upsdrvctl start >/dev/null 2>&1 && \
>> echo -n " (upsdrvctl failed)"
>> start-stop-daemon -S -q -p $upsd_pid -x $upsd >/dev/null 2>&1
>> ;;
>> stop)
>> start-stop-daemon -K -o -q -p $upsd_pid -n upsd >/dev/null 2>&1
>> ! $upsdrvctl stop >/dev/null 2>&1 && \
>> echo -n " (upsdrvctl failed)"
>> ;;
>> esac
>> ;;
>> n|N|no|NO|No|*)
>> return 1
>> ;;
>> esac
>> }
>>
>> start_stop_client () {
>> case "$START_UPSMON" in
>> y|Y|yes|YES|Yes)
>> case "$1" in
>> start)
>> start-stop-daemon -S -q -p $upsmon_pid -x $upsmon >/dev/null 2>&1
>> ;;
>> stop)
>> start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon >/dev/null
>> 2>&1
>> ;;
>> esac
>> ;;
>> n|N|no|NO|No|*)
>> return 1
>> ;;
>> esac
>> }
>>
>> case "$1" in
>>
>> start)
>> echo -n "Starting $DESC:"
>> check_var_directory
>> start_stop_server start && echo -n " upsd"
>> start_stop_client start && echo -n " upsmon"
>> echo "."
>> ;;
>>
>> stop)
>> echo -n "Stopping $DESC:"
>> start_stop_server stop && echo -n " upsd"
>> start_stop_client stop && echo -n " upsmon"
>> echo "."
>> ;;
>>
>> reload)
>> $upsd -c reload >/dev/null 2>&1
>> $upsmon -c reload >/dev/null 2>&1
>> ;;
>>
>> restart|force-reload)
>> echo -n "Restarting $DESC:"
>> start_stop_client stop
>> start_stop_server stop
>> sleep 5
>> check_var_directory
>> start_stop_server start && echo -n " upsd"
>> start_stop_client start && echo -n " upsmon"
>> echo "."
>> ;;
>>
>> poweroff)
>> 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 $upsmon -K >/dev/null 2>&1 ; then
>> echo "Shutting down the UPS ..."
>> sleep 1
>> if $upsdrvctl shutdown ; then
>> sleep 5
>> echo -n "Waiting for UPS to cut the power"
>> else
>> echo "Shutdown failed."
>> echo -n "Waiting for UPS batteries to run down"
>> 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
>> else
>> if [ -z "$flag" ] ; then
>> echo "##########################################################"
>> echo "## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##"
>> echo "## ##"
>> echo "## Please read the Manual page upsmon.conf(5) ##"
>> echo "##########################################################"
>> fi
>> fi
>> ;;
>>
>> *)
>> N=/etc/init.d/$NAME
>> echo "Usage: $N {start|stop|reload|restart|force-reload|poweroff}" >&2
>> exit 1
>> ;;
>>
>> esac
>>
>> exit 0
>> Since I do not have much knowledge on how the Linux system boots and
>> shutdown I have spent the last several days searching for how the scrips
>> /etc/init.d are supposed to work but every thing I have found is a
>> little different than what I find on my Ubuntu system. Does this script
>> ever get called with poweroff?
>>
>> _______________________________________________
>> 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