Blame kea-systemd.patch

5fc4ba
From 09ff7038ea23565e923179682ba96f5aa2d0f0c7 Mon Sep 17 00:00:00 2001
5fc4ba
From: Jiri Popelka <jpopelka@redhat.com>
5fc4ba
Date: Tue, 19 Aug 2014 17:16:50 +0200
5fc4ba
Subject: [PATCH] Systemd service unit files.
5fc4ba
5fc4ba
As of August 2014, all Linux distributions include systemd and most of
5fc4ba
them enable it by default.
5fc4ba
https://en.wikipedia.org/wiki/Systemd#Adoption
5fc4ba
5fc4ba
There are many systemd HOWTOs, like:
5fc4ba
https://wiki.archlinux.org/index.php/systemd
5fc4ba
https://coreos.com/docs/launching-containers/launching/getting-started-with-systemd/
5fc4ba
https://fedoraproject.org/wiki/Packaging:Systemd
5fc4ba
5fc4ba
For description of options in the service files, see:
5fc4ba
http://www.freedesktop.org/software/systemd/man/systemd.unit.html
5fc4ba
http://www.freedesktop.org/software/systemd/man/systemd.service.html
5fc4ba
5fc4ba
Installation of these files is turned on with --enable-systemd
5fc4ba
configure option. They are installed into
5fc4ba
PREFIX/lib/systemd/system/ by default. One can also
5fc4ba
use --with-systemd-unitdir to specify another directory.
5fc4ba
5fc4ba
For now the template files reside in src/bin/keactrl/
5fc4ba
as I haven't figured out a better place.
5fc4ba
---
5fc4ba
 configure.ac                             | 12 ++++++++++
5fc4ba
 src/bin/keactrl/Makefile.am              | 39 ++++++++++++++++++++++++++++++--
5fc4ba
 src/bin/keactrl/kea-dhcp-ddns.service.in | 12 ++++++++++
5fc4ba
 src/bin/keactrl/kea-dhcp4.service.in     | 12 ++++++++++
5fc4ba
 src/bin/keactrl/kea-dhcp6.service.in     | 12 ++++++++++
5fc4ba
 tools/path_replacer.sh.in                |  4 +++-
5fc4ba
 6 files changed, 88 insertions(+), 3 deletions(-)
5fc4ba
 create mode 100644 src/bin/keactrl/kea-dhcp-ddns.service.in
5fc4ba
 create mode 100644 src/bin/keactrl/kea-dhcp4.service.in
5fc4ba
 create mode 100644 src/bin/keactrl/kea-dhcp6.service.in
5fc4ba
5fc4ba
diff --git a/configure.ac b/configure.ac
5fc4ba
index f0dbc4f..3dc4383 100644
5fc4ba
--- a/configure.ac
5fc4ba
+++ b/configure.ac
5fc4ba
@@ -1344,6 +1344,18 @@ if test "x$VALGRIND" != "xno"; then
5fc4ba
    found_valgrind="found"
5fc4ba
 fi
5fc4ba
 
5fc4ba
+AC_ARG_ENABLE([systemd],
5fc4ba
+       AS_HELP_STRING([--enable-systemd], [enable systemd support]),
5fc4ba
+       [use_systemd=$enableval], [use_systemd=no])
5fc4ba
+AM_CONDITIONAL(USE_SYSTEMD, test "x$use_systemd" != "xno")
5fc4ba
+AC_SUBST(USE_SYSTEMD)
5fc4ba
+
5fc4ba
+AC_ARG_WITH([systemd-unitdir],
5fc4ba
+       AS_HELP_STRING([--with-systemd-unitdir=PATH],
5fc4ba
+                      [specify exact directory for systemd service files, defaults to PREFIX/lib/systemd/system/]),
5fc4ba
+       [SYSTEMD_UNITDIR=$withval], [SYSTEMD_UNITDIR="${prefix}/lib/systemd/system"])
5fc4ba
+AC_SUBST(SYSTEMD_UNITDIR)
5fc4ba
+
5fc4ba
 # Check for optreset in unistd.h. On BSD systems the optreset is
5fc4ba
 # used to reset the state of getopt() function. Resetting its state
5fc4ba
 # is required if command line arguments are parsed multiple times
5fc4ba
diff --git a/src/bin/keactrl/Makefile.am b/src/bin/keactrl/Makefile.am
5fc4ba
index a2d2a82..05b1c9e 100644
5fc4ba
--- a/src/bin/keactrl/Makefile.am
5fc4ba
+++ b/src/bin/keactrl/Makefile.am
5fc4ba
@@ -31,9 +31,36 @@ endif
7750dd
 kea.conf: kea.conf.pre
7750dd
 	$(top_srcdir)/tools/path_replacer.sh $(top_srcdir)/src/bin/keactrl/kea.conf.pre $@
5fc4ba
 
5fc4ba
+INSTALL_TARGETS = install-empty
5fc4ba
+
5fc4ba
 if INSTALL_CONFIGURATIONS
5fc4ba
 
5fc4ba
-install-data-local:
5fc4ba
+INSTALL_TARGETS += install-config-files
5fc4ba
+
5fc4ba
+endif
5fc4ba
+
5fc4ba
+if USE_SYSTEMD
5fc4ba
+
5fc4ba
+EXTRA_DIST += kea-dhcp4.service.in kea-dhcp6.service.in kea-dhcp-ddns.service.in
5fc4ba
+DISTCLEANFILES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
5fc4ba
+BUILT_SOURCES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
5fc4ba
+INSTALL_TARGETS += install-systemd-files
5fc4ba
+
5fc4ba
+endif
5fc4ba
+
5fc4ba
+kea-dhcp4.service: kea-dhcp4.service.in
5fc4ba
+	$(top_srcdir)/tools/path_replacer.sh $< $@
5fc4ba
+
5fc4ba
+kea-dhcp6.service: kea-dhcp6.service.in
5fc4ba
+	$(top_srcdir)/tools/path_replacer.sh $< $@
5fc4ba
+
5fc4ba
+kea-dhcp-ddns.service: kea-dhcp-ddns.service.in
5fc4ba
+	$(top_srcdir)/tools/path_replacer.sh $< $@
5fc4ba
+
5fc4ba
+install-empty:
5fc4ba
+	:
5fc4ba
+
5fc4ba
+install-config-files:
5fc4ba
 	$(mkinstalldirs) $(DESTDIR)/@sysconfdir@/@PACKAGE@
5fc4ba
 	for f in $(CONFIGFILES) ; do	\
5fc4ba
 	  if test ! -f $(DESTDIR)$(sysconfdir)/@PACKAGE@/$$f; then	\
5fc4ba
@@ -41,4 +68,12 @@ install-data-local:
5fc4ba
 	  fi ;	\
5fc4ba
 	done
5fc4ba
 
5fc4ba
-endif
5fc4ba
+install-systemd-files:
5fc4ba
+	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNITDIR)
5fc4ba
+	$(INSTALL_DATA) kea-dhcp4.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp4.service
5fc4ba
+	$(INSTALL_DATA) kea-dhcp6.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp6.service
5fc4ba
+	$(INSTALL_DATA) kea-dhcp-ddns.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp-ddns.service
5fc4ba
+
5fc4ba
+install-data-local: $(INSTALL_TARGETS)
5fc4ba
+
5fc4ba
+uninstall-local: $(UNINSTALL_TARGETS)
5fc4ba
diff --git a/src/bin/keactrl/kea-dhcp-ddns.service.in b/src/bin/keactrl/kea-dhcp-ddns.service.in
5fc4ba
new file mode 100644
5fc4ba
index 0000000..d1e0526
5fc4ba
--- /dev/null
5fc4ba
+++ b/src/bin/keactrl/kea-dhcp-ddns.service.in
5fc4ba
@@ -0,0 +1,12 @@
5fc4ba
+[Unit]
5fc4ba
+Description=Kea DHCP-DDNS Server
5fc4ba
+Documentation=man:kea-dhcp-ddns(8)
5fc4ba
+Wants=network-online.target
5fc4ba
+After=network-online.target
5fc4ba
+After=time-sync.target
5fc4ba
+
5fc4ba
+[Service]
5fc4ba
+ExecStart=@sbindir@/kea-dhcp-ddns -c @sysconfdir@/kea/kea.conf
5fc4ba
+
5fc4ba
+[Install]
5fc4ba
+WantedBy=multi-user.target
5fc4ba
diff --git a/src/bin/keactrl/kea-dhcp4.service.in b/src/bin/keactrl/kea-dhcp4.service.in
5fc4ba
new file mode 100644
5fc4ba
index 0000000..80977d6
5fc4ba
--- /dev/null
5fc4ba
+++ b/src/bin/keactrl/kea-dhcp4.service.in
5fc4ba
@@ -0,0 +1,12 @@
5fc4ba
+[Unit]
5fc4ba
+Description=Kea DHCPv4 Server
5fc4ba
+Documentation=man:kea-dhcp4(8)
5fc4ba
+Wants=network-online.target
5fc4ba
+After=network-online.target
5fc4ba
+After=time-sync.target
5fc4ba
+
5fc4ba
+[Service]
5fc4ba
+ExecStart=@sbindir@/kea-dhcp4 -c @sysconfdir@/kea/kea.conf
5fc4ba
+
5fc4ba
+[Install]
5fc4ba
+WantedBy=multi-user.target
5fc4ba
diff --git a/src/bin/keactrl/kea-dhcp6.service.in b/src/bin/keactrl/kea-dhcp6.service.in
5fc4ba
new file mode 100644
5fc4ba
index 0000000..c24f584
5fc4ba
--- /dev/null
5fc4ba
+++ b/src/bin/keactrl/kea-dhcp6.service.in
5fc4ba
@@ -0,0 +1,12 @@
5fc4ba
+[Unit]
5fc4ba
+Description=Kea DHCPv6 Server
5fc4ba
+Documentation=man:kea-dhcp6(8)
5fc4ba
+Wants=network-online.target
5fc4ba
+After=network-online.target
5fc4ba
+After=time-sync.target
5fc4ba
+
5fc4ba
+[Service]
5fc4ba
+ExecStart=@sbindir@/kea-dhcp6 -c @sysconfdir@/kea/kea.conf
5fc4ba
+
5fc4ba
+[Install]
5fc4ba
+WantedBy=multi-user.target
5fc4ba
diff --git a/tools/path_replacer.sh.in b/tools/path_replacer.sh.in
5fc4ba
index 43d7bff..82625ca 100644
5fc4ba
--- a/tools/path_replacer.sh.in
5fc4ba
+++ b/tools/path_replacer.sh.in
5fc4ba
@@ -27,12 +27,14 @@
5fc4ba
 prefix=@prefix@
5fc4ba
 sysconfdir=@sysconfdir@
5fc4ba
 localstatedir=@localstatedir@
5fc4ba
+sbindir=@sbindir@
5fc4ba
 
5fc4ba
 echo "Replacing \@prefix\@ with ${prefix}"
5fc4ba
 echo "Replacing \@sysconfdir\@ with ${sysconfdir}"
5fc4ba
 echo "Replacing \@localstatedir\@ with ${localstatedir}"
5fc4ba
+echo "Replacing \@sbindir\@ with ${sbindir}"
5fc4ba
 
5fc4ba
 echo "Input file: $1"
5fc4ba
 echo "Output file: $2"
5fc4ba
 
5fc4ba
-sed -e "s+\@localstatedir\@+${localstatedir}+g; s+\@prefix@+${prefix}+g; s+\@sysconfdir@+${sysconfdir}+g" $1 > $2
5fc4ba
+sed -e "s+\@localstatedir\@+${localstatedir}+g; s+\@prefix\@+${prefix}+g; s+\@sysconfdir\@+${sysconfdir}+g; s+\@sbindir\@+${sbindir}+g" $1 > $2
5fc4ba
-- 
5fc4ba
1.9.3
5fc4ba