kea/kea-systemd.patch

157 lines
5.1 KiB
Diff
Raw Normal View History

diff --git a/configure.ac b/configure.ac
2017-10-26 11:42:16 +00:00
index 46780d5..43c57b1 100644
--- a/configure.ac
+++ b/configure.ac
2017-10-26 11:42:16 +00:00
@@ -1152,6 +1152,18 @@ if test "x$VALGRIND" != "xno"; then
found_valgrind="found"
fi
+AC_ARG_ENABLE([systemd],
+ AS_HELP_STRING([--enable-systemd], [enable systemd support]),
+ [use_systemd=$enableval], [use_systemd=no])
+AM_CONDITIONAL(USE_SYSTEMD, test "x$use_systemd" != "xno")
+AC_SUBST(USE_SYSTEMD)
+
+AC_ARG_WITH([systemd-unitdir],
+ AS_HELP_STRING([--with-systemd-unitdir=PATH],
+ [specify exact directory for systemd service files, defaults to PREFIX/lib/systemd/system/]),
+ [SYSTEMD_UNITDIR=$withval], [SYSTEMD_UNITDIR="${prefix}/lib/systemd/system"])
+AC_SUBST(SYSTEMD_UNITDIR)
+
# Check for optreset in unistd.h. On BSD systems the optreset is
# used to reset the state of getopt() function. Resetting its state
# is required if command line arguments are parsed multiple times
2017-10-26 11:42:16 +00:00
diff --git a/tools/path_replacer.sh.in b/tools/path_replacer.sh.in
index f444afc..2ce8b3b 100644
--- a/tools/path_replacer.sh.in
+++ b/tools/path_replacer.sh.in
@@ -19,12 +19,14 @@
prefix=@prefix@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
+sbindir=@sbindir@
echo "Replacing \@prefix\@ with ${prefix}"
echo "Replacing \@sysconfdir\@ with ${sysconfdir}"
echo "Replacing \@localstatedir\@ with ${localstatedir}"
+echo "Replacing \@sbindir\@ with ${sbindir}"
echo "Input file: $1"
echo "Output file: $2"
-sed -e "s@SEP@\@localstatedir\@@SEP@${localstatedir}@SEP@g; s@SEP@\@prefix\@@SEP@${prefix}@SEP@g; s@SEP@\@sysconfdir\@@SEP@${sysconfdir}@SEP@g" $1 > $2
+sed -e "s@SEP@\@localstatedir\@@SEP@${localstatedir}@SEP@g; s@SEP@\@prefix\@@SEP@${prefix}@SEP@g; s@SEP@\@sysconfdir\@@SEP@${sysconfdir}@SEP@g; s@SEP@\@sbindir\@@SEP@${sbindir}@SEP@g" $1 > $2
diff --git a/src/bin/keactrl/kea-dhcp-ddns.service.in b/src/bin/keactrl/kea-dhcp-ddns.service.in
new file mode 100644
index 0000000..d1e0526
--- /dev/null
+++ b/src/bin/keactrl/kea-dhcp-ddns.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kea DHCP-DDNS Server
+Documentation=man:kea-dhcp-ddns(8)
+Wants=network-online.target
+After=network-online.target
+After=time-sync.target
+
+[Service]
2018-05-17 16:44:28 +00:00
+ExecStart=@sbindir@/kea-dhcp-ddns -c @sysconfdir@/kea/kea-dhcp-ddns.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/bin/keactrl/kea-dhcp4.service.in b/src/bin/keactrl/kea-dhcp4.service.in
new file mode 100644
index 0000000..80977d6
--- /dev/null
+++ b/src/bin/keactrl/kea-dhcp4.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kea DHCPv4 Server
+Documentation=man:kea-dhcp4(8)
+Wants=network-online.target
+After=network-online.target
+After=time-sync.target
+
+[Service]
2018-05-17 16:44:28 +00:00
+ExecStart=@sbindir@/kea-dhcp4 -c @sysconfdir@/kea/kea-dhcp4.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/bin/keactrl/kea-dhcp6.service.in b/src/bin/keactrl/kea-dhcp6.service.in
new file mode 100644
index 0000000..c24f584
--- /dev/null
+++ b/src/bin/keactrl/kea-dhcp6.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kea DHCPv6 Server
+Documentation=man:kea-dhcp6(8)
+Wants=network-online.target
+After=network-online.target
+After=time-sync.target
+
+[Service]
2018-05-17 16:44:28 +00:00
+ExecStart=@sbindir@/kea-dhcp6 -c @sysconfdir@/kea/kea-dhcp6.conf
+
+[Install]
+WantedBy=multi-user.target
2018-02-14 18:59:13 +00:00
diff --git a/src/bin/keactrl/Makefile.am b/src/bin/keactrl/Makefile.am
index 9eb3da9..b556fcc 100644
--- a/src/bin/keactrl/Makefile.am
+++ b/src/bin/keactrl/Makefile.am
@@ -50,6 +50,8 @@ kea-ctrl-agent.conf: kea-ctrl-agent.conf.pre
$(top_builddir)/tools/path_replacer.sh \
$(top_srcdir)/src/bin/keactrl/kea-ctrl-agent.conf.pre $@
+INSTALL_TARGETS = install-empty
+
if INSTALL_CONFIGURATIONS
# Since Kea 1.3.0 release we have 4 different Kea configuration files
@@ -60,6 +62,31 @@ if INSTALL_CONFIGURATIONS
# To preserve any user modifications to the old version of the file,
# this old file is backed up as keactrl.conf.bak.
install-data-local:
+INSTALL_TARGETS += install-config-files
+
+endif
+
+if USE_SYSTEMD
+
+EXTRA_DIST += kea-dhcp4.service.in kea-dhcp6.service.in kea-dhcp-ddns.service.in
+DISTCLEANFILES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
+BUILT_SOURCES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
+INSTALL_TARGETS += install-systemd-files
+
+endif
+
+kea-dhcp4.service: kea-dhcp4.service.in
+ $(top_builddir)/tools/path_replacer.sh $< $@
+
+kea-dhcp6.service: kea-dhcp6.service.in
+ $(top_builddir)/tools/path_replacer.sh $< $@
+
+kea-dhcp-ddns.service: kea-dhcp-ddns.service.in
+ $(top_builddir)/tools/path_replacer.sh $< $@
+
+install-empty:
+
+install-config-files:
$(mkinstalldirs) $(DESTDIR)/@sysconfdir@/@PACKAGE@
for f in $(CONFIGFILES) ; do \
if test -f $(DESTDIR)$(sysconfdir)/@PACKAGE@/$$f && \
@@ -72,4 +99,12 @@ install-data-local:
fi; \
done
-endif
+install-systemd-files:
+ $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNITDIR)
+ $(INSTALL_DATA) kea-dhcp4.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp4.service
+ $(INSTALL_DATA) kea-dhcp6.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp6.service
+ $(INSTALL_DATA) kea-dhcp-ddns.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp-ddns.service
+
+install-data-local: $(INSTALL_TARGETS)
+
+uninstall-local: $(UNINSTALL_TARGETS)