On mån, 2010-08-30 at 19:05 +0200, Martin Pitt wrote:
> Michael Biebl [2010-08-30 12:14 +0200]:
> > Martin, what do you think?
> 
> I like the D-BUS query approach. It avoids doing extra stuff at each
> startup with PID files (which would involve writing to the disk), and
> also avoids having to clean up stale pid files, etc.
> 
> Martin

Similar patch to previous one, except for UPower this time.

Tested on host and in pbuilder chroot.


-- 
Regards,
Andreas Henriksson
--- upower-0.9.5/debian/upower.postinst	2010-08-30 20:49:28.000000000 +0200
+++ upower-0.9.5.fixed/debian/upower.postinst	2010-08-30 20:39:29.000000000 +0200
@@ -26,9 +26,17 @@
         mv_conffile "/etc/UPower.conf" "/etc/UPower/UPower.conf"
     fi
 
-    # restart upowerd
-    if start-stop-daemon --stop --quiet --exec /usr/lib/upower/upowerd; then
-	upower --version >/dev/null || true # will trigger through D-Bus activation
+    # restart upowerd (when dbus is available == no chroot)
+    if [ -S /var/run/dbus/system_bus_socket ] ; then
+        pid=$(dbus-send --system --dest=org.freedesktop.DBus --print-reply \
+          /org/freedesktop/DBus \
+          org.freedesktop.DBus.GetConnectionUnixProcessID \
+          string:'org.freedesktop.UPower' 2>/dev/null \
+          | awk '/uint32/{print $2}')
+        if [ -n "$pid" ]; then
+            kill $pid
+	    upower --version >/dev/null || true # will trigger through D-Bus activation
+        fi
     fi
 fi
 

Reply via email to