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

Tested patch attached for your convenience.

(maybe the udev trigger should be skipped as well in a chroot, but I
guess it's harmless and triggering udev on hosts not running dbus might
still be a good idea?)


-- 
Regards,
Andreas Henriksson
--- udisks-1.0.1+git20100614.orig/debian/udisks.postinst	2010-06-14 16:11:43.000000000 +0200
+++ udisks-1.0.1+git20100614/debian/udisks.postinst	2010-08-30 20:25:05.000000000 +0200
@@ -2,9 +2,17 @@
 set -e
 
 if [ "$1" = "configure" ]; then
-    # stop udisks-daemon
-    if start-stop-daemon --stop --quiet --exec /usr/lib/udisks/udisks-daemon; then
-	DO_RESTART=1
+    # stop udisks-daemon (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.UDisks' 2>/dev/null \
+	  | awk '/uint32/{print $2}')
+        if [ -n "$pid" ]; then
+            kill $pid
+            DO_RESTART=1
+        fi
     fi
 
     # migrate DeviceKit-disks mtab on upgrade

Reply via email to