James Northcott / Chief Systems
2011-Jul-18 21:01 UTC
[Nut-upsuser] CyberPower USB UPS fails to cut power during shutdown
Hi, I have a CyberPower UPS connected to a Ubuntu karmic machine. All functions are working well. I can use upsc to see all the UPS parameters, power loss and battery low events are correctly detected, and shutdown is correctly initiated. If I run upsdrvctl shutdown, the UPS cuts power immediately. However, if I simulate a shutdown with upsmon -c fsd, the UPS fails to cut power. The normal halt procedure completes, and my machine turns itself off and stays off. The relevant part of the shutdown script is: flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/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 log_action_msg "Shutting down the UPS ..." # log_action_msg "Restarting udev to give USB access" # /etc/init.d/udev start # sleep 10 log_action_msg "Running $upsdrvctl shutdown" if $upsdrvctl shutdown ; then sleep 5 log_action_msg "Waiting for UPS to cut the power" log_end_msg 0 else log_action_msg "Shutdown failed." log_action_msg "Waiting for UPS batteries to run down" log_end_msg 0 fi log_action_msg "UPS should now be off!" sleep 10 if [ "$wait_delay" ] ; then log_action_msg " (will reboot after $wait_delay) ..." sleep "$wait_delay" /etc/init.d/reboot stop fi else log_action_msg "Power down flag is not set (UPS shutdown not needed)" fi else if [ -z "$flag" ] ; then log_daemon_msg "##########################################################" log_progress_msg "## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##" log_progress_msg "## ##" log_progress_msg "## Please read the Manual page upsmon.conf(5) ##" log_progress_msg "##########################################################" log_end_msg 0 fi fi This is part of /etc/init.d/nut, which gets called by /etc/init.d/halt at the correct time. This script is bundled with the ubuntu package (version 2.4.1-3ubuntu2) If I run /etc/init.d/nut poweroff myself, the UPS receives the command and cuts power. When I run the script directly, I see on the console: Shutting down the UPS ... Running /sbin/upsdrvctl shutdown When the script is called from the halt routines, I see: Shutting down the UPS ... Will now halt The "Will now halt" message is from /etc/init.d/halt, and indicates that we returned to that script instead of having the power cut as expected. I thought that the problem might be that the USB device is no longer available, so I tried the commented lines above to restart udev to restore access to USB devices. This didn't work. I also tried specifying that the upsdrvctl command run as root, with $upsdrvctl -u root shutdown - this also didn't work. Does anyone have any ideas on why the shutdown command is failing when run as part of the halt process? Or do you have any pointers on debugging the halt process? Thanks, James
Apparently Analagous Threads
- Bug#742397: xen-utils-common: /etc/init.d/dom0weight is hardcoded to use xm
- Bug#678719: xen-utils-common: please label all created directories for SE Linux
- Bug#764912: xen-utils-common: needs to apply SE Linux labels after creating directories in start script
- Bug#597403: xen-utils-common: need to run restorecon in /etc/init.d/xend on SE Linux systems
- ctdb event script 50.samba does not start smbd