Install a systemd service file if systemd is used
authorBenedikt Morbach <benedikt.morbach@googlemail.com>
Thu, 19 Jan 2012 18:10:38 +0000 (19:10 +0100)
committerDavid Zeuthen <davidz@redhat.com>
Sat, 21 Jan 2012 21:50:03 +0000 (16:50 -0500)
This makes dbus defer starting udisks to systemd instead of doing it
itself and thus puts the daemon under proper systemd supervision.

Can be disabled by passing --without-systemdsystemunitdir to configure

Signed-off-by: David Zeuthen <davidz@redhat.com>
Makefile.am
configure.ac
data/Makefile.am
data/org.freedesktop.UDisks2.service.in
data/udisks.service.in [new file with mode: 0644]

index d78958b..9631f73 100644 (file)
@@ -8,7 +8,8 @@ EXTRA_DIST =                    \
        HACKING                 \
        $(NULL)
 
-DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
+DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc \
+       --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
 
 clean-local :
        rm -f *~
index 9794ef1..04c0bc4 100644 (file)
@@ -57,6 +57,16 @@ PKG_CHECK_MODULES(LIBATASMART, [libatasmart >= 0.17])
 AC_SUBST(LIBATASMART_CFLAGS)
 AC_SUBST(LIBATASMART_LIBS)
 
+# systemd
+AC_ARG_WITH([systemdsystemunitdir],
+            AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
+            [],
+            [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+if test "x$with_systemdsystemunitdir" != "xno"; then
+  AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+fi
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir"])
+
 # Internationalization
 #
 
index dfda50a..6118d47 100644 (file)
@@ -1,11 +1,11 @@
 
 NULL =
 
-servicedir       = $(datadir)/dbus-1/system-services
-service_in_files = org.freedesktop.UDisks2.service.in
-service_DATA     = $(service_in_files:.service.in=.service)
+dbusservicedir       = $(datadir)/dbus-1/system-services
+dbusservice_in_files = org.freedesktop.UDisks2.service.in
+dbusservice_DATA     = $(dbusservice_in_files:.service.in=.service)
 
-$(service_DATA): $(service_in_files) Makefile
+$(dbusservice_DATA): $(dbusservice_in_files) Makefile
        @sed -e "s|\@privlibdir\@|$(privlibdir)|" $< > $@
 
 dbusconfdir = $(sysconfdir)/dbus-1/system.d
@@ -15,15 +15,26 @@ dbusconf_DATA = $(dbusconf_in_files:.conf.in=.conf)
 $(dbusconf_DATA): $(dbusconf_in_files) Makefile
        cp $< $@
 
+systemdservice_in_files = udisks.service.in
+
+if HAVE_SYSTEMD
+systemdservicedir       = $(systemdsystemunitdir)
+systemdservice_DATA     = $(systemdservice_in_files:.service.in=.service)
+
+$(systemdservice_DATA): $(systemdservice_in_files) Makefile
+       @sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
+
 udevrulesdir = $(slashlibdir)/udev/rules.d
 udevrules_DATA = 80-udisks2.rules
 
 EXTRA_DIST =                                           \
        80-udisks2.rules                                \
        org.freedesktop.UDisks2.xml                     \
-       $(service_in_files)                             \
+       $(systemdservice_in_files)                      \
+       $(dbusservice_in_files)                         \
        $(dbusconf_in_files)                            \
        $(NULL)
 
 clean-local :
-       rm -f *~ $(service_DATA) $(dbusconf_DATA)
+       rm -f *~ $(dbusservice_DATA) $(dbusconf_DATA) $(systemdservice_DATA)
index f127a69..3d5d0c1 100644 (file)
@@ -2,4 +2,4 @@
 Name=org.freedesktop.UDisks2
 Exec=@privlibdir@/udisksd --no-debug
 User=root
-
+SystemdService=udisks.service
diff --git a/data/udisks.service.in b/data/udisks.service.in
new file mode 100644 (file)
index 0000000..234fc33
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Enumerate, Query and Manipulate Storage Devices
+
+[Service]
+Type=dbus
+BusName=org.freedesktop.UDisks2
+ExecStart=@privlibdir@/udisksd --no-debug