From 9d1524b7de1cfcc3615cd39cf7a8df82904113cd Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 14 Aug 2013 18:46:56 +0200 Subject: [PATCH] systemd: ship lldpd.service file if possible --- configure.ac | 7 ++++++- src/daemon/Makefile.am | 7 +++++++ debian/lldpd.service => src/daemon/lldpd.service.in | 6 +++--- 3 files changed, 16 insertions(+), 4 deletions(-) rename debian/lldpd.service => src/daemon/lldpd.service.in (56%) diff --git a/configure.ac b/configure.ac index b95035ce..504b3569 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile AC_CONFIG_FILES([osx/Makefile osx/distribution.xml osx/im.bernat.lldpd.plist]) AC_CONFIG_FILES([osx/scripts/preinstall], [chmod +x osx/scripts/preinstall]) AC_CONFIG_FILES([osx/scripts/postinstall], [chmod +x osx/scripts/postinstall]) +AC_CONFIG_FILES([src/daemon/lldpd.service]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args]) @@ -178,7 +179,11 @@ if test x"$with_json" = x"yes"; then fi # OS X launchd support -lldp_ARG_WITH([launchd-daemons-path], [Path to system-wide daemons configuration files (OSX)], [/Library/LaunchDaemons]) +lldp_ARG_WITH([launchd-daemons-path], [Directory for launchd configuration file (OSX)], [/Library/LaunchDaemons]) + +# Systemd +lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files], + [$($PKG_CONFIG --variable=systemdsystemunitdir systemd || echo no)]) # Privsep settings lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd]) diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 339c2913..54dda7b1 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -99,3 +99,10 @@ event.c: $(top_builddir)/libevent/libevent.la $(top_builddir)/libevent/libevent.la: $(top_srcdir)/libevent/*.c $(top_srcdir)/libevent/*.h (cd $(top_builddir)/libevent && $(MAKE)) endif + +## systemd service file +install-data-local: + [ x"@SYSTEMDSYSTEMUNITDIR@" = x"no" ] || install -m 0755 -d $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@ + [ x"@SYSTEMDSYSTEMUNITDIR@" = x"no" ] || install -m 0644 -d lldpd.service $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@ +uninstall-local: + [ x"@LAUNCHD_DAEMONS_PATH@" = x"no" ] || rm -f $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@/lldpd.service diff --git a/debian/lldpd.service b/src/daemon/lldpd.service.in similarity index 56% rename from debian/lldpd.service rename to src/daemon/lldpd.service.in index aee82876..61e157b6 100644 --- a/debian/lldpd.service +++ b/src/daemon/lldpd.service.in @@ -6,9 +6,9 @@ Documentation=man:lldpd(8) Type=notify NotifyAccess=main EnvironmentFile=-/etc/default/lldpd -ExecStart=/usr/sbin/lldpd $DAEMON_ARGS -ExecStartPre=mkdir -p /var/run/lldpd/etc -ExecStartPre=cp /etc/localtime /var/run/lldpd/etc/localtime +ExecStart=@prefix@/sbin/lldpd $DAEMON_ARGS +ExecStartPre=mkdir -p @PRIVSEP_CHROOT@/etc +ExecStartPre=cp /etc/localtime @PRIVSEP_CHROOT@/etc/localtime Restart=on-failure [Install] -- 2.39.5