OK, I have a simple fix, which keeps the powerfail file in /var/..., but it probably requires the user to edit /etc/apcupsd/killpower and uncomment a couple of lines so /usr and /var are mounted read only before apcupsd is executed. Some users may need to write more sophisticated stuff in more complex situations.
The fix also removes the unnecessary check for /var/spool/apcupsd/powerfail in ups-monitor: apcupsd already checks, and in any case the read-only mount of /var potentially happens later, so the test may give the wrong result.
Patch follows... Regards, Alvaro.
-------------------------------------------------------------------------------
diff -ruN apcupsd-3.10.16.ORIG/configure apcupsd-3.10.16/configure
--- apcupsd-3.10.16.ORIG/configure 2004-10-22 02:31:43.000000000 -0700
+++ apcupsd-3.10.16/configure 2005-03-29 01:37:06.000000000 -0800
@@ -13846,7 +13846,8 @@
platforms/etc/changeme \
platforms/etc/commfailure \
platforms/etc/commok \
- platforms/etc/mainsback
+ platforms/etc/mainsback \
+ platforms/etc/killpower \
platforms/etc/masterconnect \
platforms/etc/mastertimeout \
platforms/etc/onbattery \
diff -ruN apcupsd-3.10.16.ORIG/debian/apcupsd.install apcupsd-3.10.16/debian/apcupsd.install
--- apcupsd-3.10.16.ORIG/debian/apcupsd.install 2005-03-28 22:48:04.000000000 -0800
+++ apcupsd-3.10.16/debian/apcupsd.install 2005-03-29 01:37:06.000000000 -0800
@@ -9,6 +9,7 @@
etc/apcupsd/apccontrol
etc/apcupsd/commfailure
etc/apcupsd/mainsback +etc/apcupsd/killpower
etc/apcupsd/commok
etc/apcupsd/masterconnect
etc/apcupsd/changeme diff -ruN apcupsd-3.10.16.ORIG/debian/changelog apcupsd-3.10.16/debian/changelog
--- apcupsd-3.10.16.ORIG/debian/changelog 2005-03-28 22:48:04.000000000 -0800
+++ apcupsd-3.10.16/debian/changelog 2005-03-29 01:37:06.000000000 -0800
@@ -1,3 +1,15 @@
+apcupsd (3.10.16-8) unstable; urgency=low
+
+ * The powerfail file lives in /var/spool/apcupsd, and some libraries
+ apcupsd depends on live in /usr/lib; if those directories are in
+ filesystems different from the root, killpower will not work (because
+ by the time it is invoked from halt, the filesystems will not be
+ mounted anymore). Add a killpower script in /etc/apcupsd with a
+ small comment indicating the potential need to mount /var and /usr
+ read-only.
+
+ -- Alvaro Martinez Echevarria <[EMAIL PROTECTED]> Mon, 28 Mar 2005 22:50:36 -0800
+
apcupsd (3.10.16-7) unstable; urgency=low
* splitted apcupsd in three packages: main, doc, cgi (Closes: #296035) diff -ruN apcupsd-3.10.16.ORIG/debian/ups-monitor apcupsd-3.10.16/debian/ups-monitor --- apcupsd-3.10.16.ORIG/debian/ups-monitor 2005-03-28 22:48:04.000000000 -0800 +++ apcupsd-3.10.16/debian/ups-monitor 2005-03-29 01:38:50.000000000 -0800 @@ -8,12 +8,12 @@
case "$1" in poweroff | killpower) + echo "" + echo -n "apcupsd: Ordering UPS to kill power... " + /etc/apcupsd/apccontrol killpower + echo "done." if [ -f /var/spool/apcupsd/powerfail ]; then echo "" - echo -n "apcupsd: Ordering UPS to kill power... " - /etc/apcupsd/apccontrol killpower - echo "done." - echo "" echo "Please ensure the UPS has powered off before rebooting." echo "Otherwise, the UPS may cut the power during the reboot!" echo "" diff -ruN apcupsd-3.10.16.ORIG/platforms/debian/ups-monitor.in apcupsd-3.10.16/platforms/debian/ups-monitor.in --- apcupsd-3.10.16.ORIG/platforms/debian/ups-monitor.in 2004-06-20 11:51:51.000000000 -0700 +++ apcupsd-3.10.16/platforms/debian/ups-monitor.in 2005-03-29 01:40:11.000000000 -0800 @@ -5,12 +5,12 @@
case "$1" in
poweroff | killpower)
+ echo ""
+ echo -n "apcupsd: Ordering UPS to kill power... "
+ @sysconfdir@/apccontrol killpower
+ echo "done."
if [ -f @PWRFAILDIR@/powerfail ]; then
echo ""
- echo -n "apcupsd: Ordering UPS to kill power... "
- @sysconfdir@/apccontrol killpower
- echo "done." - echo ""
echo "Please ensure the UPS has powered off before rebooting."
echo "Otherwise, the UPS may cut the power during the reboot!"
echo ""
diff -ruN apcupsd-3.10.16.ORIG/platforms/etc/Makefile.in apcupsd-3.10.16/platforms/etc/Makefile.in
--- apcupsd-3.10.16.ORIG/platforms/etc/Makefile.in 2003-11-08 02:22:52.000000000 -0800
+++ apcupsd-3.10.16/platforms/etc/Makefile.in 2005-03-29 01:37:06.000000000 -0800
@@ -28,7 +28,7 @@
fi; \
$(INSTALL_DATA) $$srcconf $(DESTDIR)$(sysconfdir)/$$dstconf; \
for src in changeme commfailure commok masterconnect \
- mastertimeout mainsback onbattery; do \
+ mastertimeout mainsback onbattery killpower; do \
if test -f $(DESTDIR)$(sysconfdir)/$$src; then \
echo " Found old $$src moving it to $$src.orig"; \
$(RMF) $(DESTDIR)$(sysconfdir)/$$src.orig; \
@@ -40,7 +40,7 @@
uninstall:
distclean: targetdistclean - $(RMF) apcupsd.conf changeme commfailure commok mainsback onbattery + $(RMF) apcupsd.conf changeme commfailure commok mainsback onbattery killpower $(RMF) masterconnect mastertimeout $(RMF) Makefile @rm -rf CVS diff -ruN apcupsd-3.10.16.ORIG/platforms/etc/killpower.in apcupsd-3.10.16/platforms/etc/killpower.in --- apcupsd-3.10.16.ORIG/platforms/etc/killpower.in 1969-12-31 16:00:00.000000000 -0800 +++ apcupsd-3.10.16/platforms/etc/killpower.in 2005-03-29 01:37:06.000000000 -0800 @@ -0,0 +1,10 @@ +#!/bin/sh +# +# This shell script if placed in /etc/apcupsd +# will be called by /etc/apcupsd/apccontrol before +# apcupsd kills the power in the UPS. You probably +# need to edit this to mount read-only /usr and /var, +# otherwise apcupsd will not run. +# mount -n -o ro /usr +# mount -n -o ro /var +exit 0
-- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]