Source: apcupsd
Followup-For: Bug #294256

The following updated patch to the init script more-or-less works with apcupsd
from squeeze (3.14.8-2), but segfaults with the version from wheezy (3.14.10-2)
for multiple acpupsd (the first does continue to work).

The patch applies to both versions cleanly, as the init script is identical.

It doesn't seem to consistantly stop the apcupsd processes though, but the PIDs
seem correct.

live well,
  vagrant

--- 3.14.10-2/etc/init.d/apcupsd        2012-05-28 01:55:29.000000000 -0700
+++ /etc/init.d/apcupsd 2013-07-11 13:31:48.000000000 -0700
@@ -15,6 +15,7 @@
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/sbin/apcupsd
 CONFIG=/etc/default/apcupsd
+CONFIGFILES=/etc/apcupsd/apcupsd*.conf
 NAME=apcupsd
 DESC="UPS power management"
 
@@ -38,23 +39,39 @@
 
                rm -f /etc/apcupsd/powerfail
 
-               if [ "`pidof apcupsd`" = "" ]
-               then
-                       start-stop-daemon --start --quiet --exec $DAEMON
-                       echo "$NAME."
-               else
-                       echo ""
-                       echo "A copy of the daemon is still running.  If you 
just stopped it,"
-                       echo "please wait about 5 seconds for it to shut down."
-                       exit 0
-               fi
+               for f in $CONFIGFILES
+               do
+                       CONF=`echo $f | sed 's|^.*/\([^.]*\)\.conf$|\1|'`
+                       PIDFILE=/var/run/$(basename ${CONF}).pid
+                       echo -n " $CONF"
+                       if [ ! -f $PIDFILE -o ! -e /proc/`cat $PIDFILE 
2>/dev/null` ]
+                       then
+                               start-stop-daemon --start --pidfile $PIDFILE 
--quiet \
+                               --exec $DAEMON -- -f $f -P $PIDFILE \
+                               || echo -n " failed!"
+                       else
+                               echo ""
+                               echo "A copy of the daemon is still running.  
If you just stopped it,"
+                               echo "please wait about 5 seconds for it to 
shut down."
+                               exit 0
+                       fi
+               done
+               echo "."
+
                ;;
 
        stop)
                echo -n "Stopping $DESC: "
-               start-stop-daemon --stop --oknodo --pidfile 
/var/run/apcupsd.pid || echo "Not Running."
-               rm -f /var/run/apcupsd.pid
-               echo "$NAME."
+               for f in $CONFIGFILES
+               do
+                       CONF=`echo $f | sed 's|^.*/\([^.]*\)\.conf$|\1|'`
+                       PIDFILE=/var/run/$(basename ${CONF}).pid
+                       echo -n " $CONF"
+                       start-stop-daemon --stop --pidfile $PIDFILE --quiet \
+                               --exec $DAEMON \
+                               || echo -n " failed: not running?"
+               done
+               echo "."
                ;;
 
        restart|force-reload)


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to