]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: systemd - configure and install
authorTomas Krizek <tomas.krizek@nic.cz>
Fri, 8 Feb 2019 11:42:18 +0000 (12:42 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:43:24 +0000 (10:43 +0100)
14 files changed:
distro/common/systemd/README.md [deleted file]
distro/common/systemd/drop-in/listen-tls.conf [deleted file]
distro/common/systemd/drop-in/listen-udp-tcp.conf [deleted file]
distro/common/systemd/drop-in/systemd-compat.conf [deleted file]
distro/common/tmpfiles/knot-resolver.conf [deleted file]
meson.build
systemd/kresd-control@.socket.in [moved from distro/common/systemd/kresd-control@.socket with 87% similarity]
systemd/kresd-tls.socket [moved from distro/common/systemd/kresd-tls.socket with 100% similarity]
systemd/kresd.socket [moved from distro/common/systemd/kresd.socket with 100% similarity]
systemd/kresd.systemd.7 [moved from distro/common/systemd/kresd.systemd.7 with 100% similarity]
systemd/kresd.target [moved from distro/common/systemd/kresd.target with 100% similarity]
systemd/kresd@.service.in [moved from distro/common/systemd/kresd@.service with 66% similarity]
systemd/meson.build [new file with mode: 0644]
systemd/tmpfiles.d/knot-resolver.conf.in [new file with mode: 0644]

diff --git a/distro/common/systemd/README.md b/distro/common/systemd/README.md
deleted file mode 100644 (file)
index 433f92f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Running Knot Resolver under systemd (or equivalent) socket activation
-=====================================================================
-
-You can use the files in this directory to run kresd under supervision
-by systemd (or any supervisor that provides equivalent file descriptor
-initialization via the interface supported by
-sd_listen_fds_with_names(3)).
-
-Usage and Configuration
------------------------
-
-See kresd.systemd(7) for details.
-
-Compatibility with older systemd
---------------------------------
-
-If you're using systemd prior to version 227, use the systemd-compat.conf
-drop-in file to use manual activation. In this case, socket files shouldn't
-be packaged, because they won't be used.
-
-Notes
------
-
-*  If you're using the upstream systemd unit files, don't forget to also include
-   kresd.systemd.7 manual page in the package.
-*  Distributions using systemd-sysv-generator should mask kresd.service to
-   be consistent with other distributions. Any use of kresd.service instead of
-   kresd@N.service is discouraged to avoid confusing the users.
-*  kresd.target should be enabled by default by linking it to systemd lib/
-   directory. Instances of kresd@.service are then added manually to
-   kresd.target when the user enables them.
diff --git a/distro/common/systemd/drop-in/listen-tls.conf b/distro/common/systemd/drop-in/listen-tls.conf
deleted file mode 100644 (file)
index 6c798f0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# /etc/systemd/system/kresd-tls.socket.d/override.conf
-
-# Configure which interfaces should kresd listen on.
-# ListenStream can be added multiple times.
-
-[Socket]
-ListenStream=192.0.2.115:853
diff --git a/distro/common/systemd/drop-in/listen-udp-tcp.conf b/distro/common/systemd/drop-in/listen-udp-tcp.conf
deleted file mode 100644 (file)
index 480767a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# /etc/systemd/system/kresd.socket.d/override.conf
-
-# Configure which interfaces should kresd listen on.
-# ListenDatagram and ListenStream can be added multiple times.
-
-[Socket]
-ListenDatagram=192.0.2.115:53
-ListenStream=192.0.2.115:53
diff --git a/distro/common/systemd/drop-in/systemd-compat.conf b/distro/common/systemd/drop-in/systemd-compat.conf
deleted file mode 100644 (file)
index d251c41..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# /usr/lib/systemd/system/kresd@.service.d/override.conf
-
-# If systemd.227+ isn't available (e.g. CentOS 7), socket activation can't be used
-# and the following modifications are required to use the service with
-# manual activation.
-
-# CAP_NET_BIND_SERVICE is necessary to be able to bind to a well-known port
-# as an unprivilidged user.
-
-# Explicit --forks=1 turns off interactive mode.
-
-[Service]
-Type=simple
-AmbientCapabilities=CAP_NET_BIND_SERVICE
-ExecStart=
-ExecStart=/usr/sbin/kresd --config=/etc/knot-resolver/kresd.conf --forks=1
-Sockets=
diff --git a/distro/common/tmpfiles/knot-resolver.conf b/distro/common/tmpfiles/knot-resolver.conf
deleted file mode 100644 (file)
index 9ac5952..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# tmpfiles.d(5) runtime directory for knot-resolver (kresd)
-#Type Path                            Mode UID           GID          Age Argument
-    d /run/knot-resolver              0750 root          root          -   -
-    d /var/cache/knot-resolver        0750 knot-resolver knot-resolver -   -
index dbbc36c5250743412213694505ae7b9f206eb585..d1c656f263933459fa6594167c5548d922ec4109 100644 (file)
@@ -36,6 +36,10 @@ data_dir = join_paths(prefix, get_option('datadir'), 'knot-resolver')
 doc_dir = join_paths(prefix, get_option('datadir'), 'doc', 'knot-resolver')
 etc_dir = join_paths(prefix, get_option('sysconfdir'), 'knot-resolver')
 sbin_dir = join_paths(prefix, get_option('sbindir'))
+systemd_cache_dir = ''
+run_dir = ''
+systemd_unit_dir = ''
+systemd_tmpfiles_dir = ''
 
 modules_dir = get_option('modules_dir')
 if modules_dir == ''
@@ -152,6 +156,11 @@ subdir('tests')
 subdir('doc')
 subdir('etc')
 
+# systemd integration
+if systemd
+  subdir('systemd')
+endif
+
 
 # summary message
 # NOTE: ternary operator in format() not supported
@@ -181,6 +190,8 @@ message('''
   systemd:              @0@'''.format(summary_systemd) + '''
     socket activation:  @0@'''.format(summary_systemd_socket) + '''
     user mode:          @0@'''.format(summary_systemd_user_mode) + '''
+    cache_dir:          @0@'''.format(systemd_cache_dir) + '''
+    run_dir:            @0@'''.format(run_dir) + '''
 
   components
     client:             @0@'''.format(summary_build_client) + '''
similarity index 87%
rename from distro/common/systemd/kresd-control@.socket
rename to systemd/kresd-control@.socket.in
index 6937436dca413d7474b729d3630fd1e4508d46db..2280f0840402628599e1f99aee2606ec56267662 100644 (file)
@@ -7,7 +7,7 @@ PartOf=kresd@%i.service
 
 [Socket]
 Service=kresd@%i.service
-ListenStream=/run/knot-resolver/control@%i
+ListenStream=@run_dir@/control@%i
 FileDescriptorName=control
 SocketMode=0660
 Slice=system-kresd.slice
similarity index 66%
rename from distro/common/systemd/kresd@.service
rename to systemd/kresd@.service.in
index 048aee01e71d8c73ca92dbdee0f15f88bbc3ba7b..c559a611ff80726e5af279087273b08c5973337f 100644 (file)
@@ -5,9 +5,9 @@ Documentation=man:kresd(8)
 
 [Service]
 Type=notify
-WorkingDirectory=/var/cache/knot-resolver
-ExecStart=/usr/sbin/kresd --config=/etc/knot-resolver/kresd.conf
-User=knot-resolver
+WorkingDirectory=@systemd_cache_dir@
+ExecStart=@sbin_dir@/kresd --config=@etc_dir@/kresd.conf
+User=@user@
 Restart=on-failure
 Sockets=kresd.socket
 Sockets=kresd-tls.socket
diff --git a/systemd/meson.build b/systemd/meson.build
new file mode 100644 (file)
index 0000000..0110675
--- /dev/null
@@ -0,0 +1,59 @@
+# systemd
+
+## paths
+# TODO user mode
+systemd_cache_dir = join_paths(
+  prefix, get_option('localstatedir'), 'cache', 'knot-resolver')
+run_dir = join_paths('/run', 'knot-resolver')
+systemd_unit_dir = join_paths(prefix, get_option('libdir'), 'systemd', 'system')
+systemd_tmpfiles_dir = join_paths(prefix, get_option('libdir'), 'tmpfiles.d')
+
+## configuration
+systemd_config = configuration_data()
+systemd_config.set('user', user)
+systemd_config.set('group', group)
+systemd_config.set('systemd_cache_dir', systemd_cache_dir)
+systemd_config.set('sbin_dir', sbin_dir)
+systemd_config.set('etc_dir', etc_dir)
+systemd_config.set('run_dir', run_dir)
+
+# TODO Restart=on-abnormal
+
+if systemd_socket
+  # unit files
+  kresd_service = configure_file(
+    input: 'kresd@.service.in',
+    output: 'kresd@.service',
+    configuration: systemd_config,
+    install_dir: systemd_unit_dir,
+  )
+  kresd_control_socket = configure_file(
+    input: 'kresd-control@.socket.in',
+    output: 'kresd-control@.socket',
+    configuration: systemd_config,
+    install_dir: systemd_unit_dir,
+  )
+
+  install_data(
+    sources: [
+      'kresd.socket',
+      'kresd-tls.socket',
+      'kresd.target',
+    ],
+    install_dir: systemd_unit_dir,
+  )
+
+  install_man('kresd.systemd.7')  # TODO amend man page + configure
+
+  # tmpfiles
+  tmpfiles = configure_file(
+    input: 'tmpfiles.d/knot-resolver.conf.in',
+    output: 'knot-resolver.conf',
+    configuration: systemd_config,
+    install_dir: systemd_tmpfiles_dir,
+  )
+
+  # TODO example drop-ins
+else
+  subdir('nosocket')
+endif
diff --git a/systemd/tmpfiles.d/knot-resolver.conf.in b/systemd/tmpfiles.d/knot-resolver.conf.in
new file mode 100644 (file)
index 0000000..75237f5
--- /dev/null
@@ -0,0 +1,4 @@
+# tmpfiles.d(5) directories for knot-resolver (kresd)
+#Type Path                            Mode UID           GID          Age Argument
+    d @run_dir@                       0750 root          root          -   -
+    d @systemd_cache_dir@             0750 @user@        @group@       -   -