[opensuse] opensuse 11.3 power down system with apcupsd (solution)

Hi, I searched for a way to power down my box at a predefined time including switching off the power from the UPS. "shutdown -h time" handles the shutdown of the system nicely, but to power down the UPS some changes have to be done: /etc/sysconfig/shutdown : HALT_POWERDOWN_INSERT="/etc/init.d/apcupsd powerdown" "try-powerdown" will only power down the UPS if it is running on battery at this time. The script /etc/init.d/apcupsd from apcupsd-3.14.6-8.1 contains a wrong path for the apcupsd-lite binary, it should be APCUPSD_LITE=/sbin/apcupsd-lite instead of APCUPSD_LITE=/usr/sbin/apcupsd-lite Additionally, the action performed in case of "powerdown)" has to be changed: it should perform action "--power-off" instead of "--killpower". "--killpower" only takes effect if the UPS is running on battery at this time. Following patch can apply the changes: --- apcupsd 2010-07-05 18:34:19.000000000 +0200 +++ apcupsd_my 2010-12-18 12:29:01.741526103 +0100 @@ -26,7 +26,7 @@ ### END INIT INFO APCUPSD=/usr/sbin/apcupsd -APCUPSD_LITE=/usr/sbin/apcupsd-lite +APCUPSD_LITE=/sbin/apcupsd-lite test -x $APCUPSD -o -x $APCUPSD_LITE || exit 5 # Shell functions sourced from /etc/rc.status: @@ -138,7 +138,7 @@ ## Special command: Instruct UPS to shutdown. sync & echo -n "Instructing UPS to powerdown " - $APCUPSD_LITE --killpower >/dev/null 2>&1 || rc_failed + $APCUPSD_LITE --power-off >/dev/null 2>&1 || rc_failed rc_status -v ;; try-powerdown) Dieter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org

On Sat, Dec 18, 2010 at 01:37:52PM +0100, Dieter Werner wrote:
Either file a bug report and attach the suggested patch or use the openSUSE Build Service (OBS) and file a submit request. For the first use the following steps: a) Call "osc search apcupsd" to see at which project apcupsd is maintained in the OBS. Ignoring all home: (OBS user name space), DISCONTINUED: (OBS namespace of discontinued products), and openSUSE: (OBS namespace of released and still with fixes feeded products) projects limit the result to the hardware project. BTW is there a more elegant way to find the main repo? b) osc maintainer hardware apcupsd will show the bug owner. Unfortunetly this doesn't result in an email address you're able to use in bugzilla. There you have to search again. :/ The second more straight way is to branch the hardware:apcupsd and apply you chnage, call osc vc apcupsd.changes and describe your change in a short sentence. If possible with a reference to bugzilla where others are able o find more details. a) osc branch hardware apcupsd b) edit apcupsd.spec and call osc vc apcupsd.changes c) osc commit d) osc sumbitrequest home:<d_werner_username>:branches:hardware \ apcupsd hardware e) You might post the submit request ID as part of this thread as a reference. Lars -- Lars Müller [ˈlaː(r)z ˈmʏlɐ] Samba Team SUSE Linux, Maxfeldstraße 5, 90409 Nürnberg, Germany

Thanks for your hints. I did some further research. I found for the part of my description which really is an error (wrong path in APCUPSD_LITE) a bug report exists already: #587635 [...]
[...]
Either file a bug report and attach the suggested patch or use the openSUSE Build Service (OBS) and file a submit request.
[...] For the rest I found my changes have an undesired side effect: the HALT_POWERDOWN_INSERT action is executed unconditionally in the /etc/init.d/halt script - also in the case it is called as reboot. This results that the ups power is switched off even in the case of a reboot (e.g. after kernel upgrade). For my purpose I solved this by an unset HALT_POWERDOWN_INSERT in the reboot) branch of the /etc/init.d/halt script. According to the name of this variable this is a correct solution as there should be no powerdown during reboot. :-) If this variable is also used for other purposes a suggestion could be to define an additional variable in the /etc/sysconfig/shutdown file, e.g. REBOOT_INSERT and in the reboot) branch of the /etc/init.d/halt overwrite the content of HALT_POWERDOWN_INSERT with the content of REBOOT_INSERT. REBOOT_INSERT could then also be set to "/etc/init.d/apcupsd try-powerdown", so that it switches off the ups power only if there is a power failure during reboot. Dieter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org

On Sat, Dec 18, 2010 at 01:37:52PM +0100, Dieter Werner wrote:
Either file a bug report and attach the suggested patch or use the openSUSE Build Service (OBS) and file a submit request. For the first use the following steps: a) Call "osc search apcupsd" to see at which project apcupsd is maintained in the OBS. Ignoring all home: (OBS user name space), DISCONTINUED: (OBS namespace of discontinued products), and openSUSE: (OBS namespace of released and still with fixes feeded products) projects limit the result to the hardware project. BTW is there a more elegant way to find the main repo? b) osc maintainer hardware apcupsd will show the bug owner. Unfortunetly this doesn't result in an email address you're able to use in bugzilla. There you have to search again. :/ The second more straight way is to branch the hardware:apcupsd and apply you chnage, call osc vc apcupsd.changes and describe your change in a short sentence. If possible with a reference to bugzilla where others are able o find more details. a) osc branch hardware apcupsd b) edit apcupsd.spec and call osc vc apcupsd.changes c) osc commit d) osc sumbitrequest home:<d_werner_username>:branches:hardware \ apcupsd hardware e) You might post the submit request ID as part of this thread as a reference. Lars -- Lars Müller [ˈlaː(r)z ˈmʏlɐ] Samba Team SUSE Linux, Maxfeldstraße 5, 90409 Nürnberg, Germany

Thanks for your hints. I did some further research. I found for the part of my description which really is an error (wrong path in APCUPSD_LITE) a bug report exists already: #587635 [...]
[...]
Either file a bug report and attach the suggested patch or use the openSUSE Build Service (OBS) and file a submit request.
[...] For the rest I found my changes have an undesired side effect: the HALT_POWERDOWN_INSERT action is executed unconditionally in the /etc/init.d/halt script - also in the case it is called as reboot. This results that the ups power is switched off even in the case of a reboot (e.g. after kernel upgrade). For my purpose I solved this by an unset HALT_POWERDOWN_INSERT in the reboot) branch of the /etc/init.d/halt script. According to the name of this variable this is a correct solution as there should be no powerdown during reboot. :-) If this variable is also used for other purposes a suggestion could be to define an additional variable in the /etc/sysconfig/shutdown file, e.g. REBOOT_INSERT and in the reboot) branch of the /etc/init.d/halt overwrite the content of HALT_POWERDOWN_INSERT with the content of REBOOT_INSERT. REBOOT_INSERT could then also be set to "/etc/init.d/apcupsd try-powerdown", so that it switches off the ups power only if there is a power failure during reboot. Dieter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
Dieter Werner
-
Lars Müller