commit:     343dd455206377eabcc66809abe255abdc751f56
Author:     Peter Leese <inbox <AT> peterleese <DOT> org>
AuthorDate: Fri Aug  8 20:54:18 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 21 01:01:29 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=343dd455

net-misc/kea: use a skeleton for kea services

Add new init & conf scripts provided by Nicolas PARLANT <nicolas.parlant <AT> 
parhuet.fr>

Signed-off-by: Peter Leese <inbox <AT> peterleese.org>
Part-of: https://github.com/gentoo/gentoo/pull/43307
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net-misc/kea/files/kea-confd-r3 |  8 +++++
 net-misc/kea/files/kea-initd-r3 | 76 +++++++++++++++++++++++++++++++++++++++++
 net-misc/kea/kea-3.0.0.ebuild   | 24 +++++++++++--
 3 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/net-misc/kea/files/kea-confd-r3 b/net-misc/kea/files/kea-confd-r3
new file mode 100644
index 000000000000..a8844bae730b
--- /dev/null
+++ b/net-misc/kea/files/kea-confd-r3
@@ -0,0 +1,8 @@
+# KEA_SVC must be defined here!
+# Available values: dhcp4 dhcp6 dhcp-ddns ctrl-agent
+KEA_SVC="@KEA_SVC@"
+
+#KEA_USER=dhcp
+#KEA_GROUP=dhcp
+#KEA_CONFIG=/etc/kea/kea-@[email protected]
+#KEA_PIDFILE=/run/kea/kea-@[email protected]@[email protected]

diff --git a/net-misc/kea/files/kea-initd-r3 b/net-misc/kea/files/kea-initd-r3
new file mode 100644
index 000000000000..d499c6c193d9
--- /dev/null
+++ b/net-misc/kea/files/kea-initd-r3
@@ -0,0 +1,76 @@
+#!/sbin/openrc-run
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+: ${KEA_USER:=dhcp}
+: ${KEA_GROUP:=dhcp}
+: ${KEA_CONFIG:=/etc/kea/${RC_SVCNAME}.conf}
+: ${KEA_PIDFILE:=/run/kea/${RC_SVCNAME}.kea-${KEA_SVC}.pid}
+
+description="kea ${KEA_SVC} services"
+command="/usr/sbin/kea-${KEA_SVC}"
+command_args="-c ${KEA_CONFIG}"
+command_user="${KEA_USER}:${KEA_GROUP}"
+pidfile="${KEA_PIDFILE}"
+required_files="${KEA_CONFIG}"
+start_stop_daemon_args="--background"
+
+extra_commands="check_kea_svc checkconfig"
+extra_started_commands="reload"
+
+check_kea_svc() {
+       if [ "${RC_SVCNAME}" = "kea" ]; then
+               eerror "You are not supposed to run this script directly."
+               eerror "Create a symlink for the kea service you want to run."
+               eerror "Symlinks should have been created during installation."
+               return 1
+       fi
+
+       case "${KEA_SVC}" in
+       dhcp4)
+           capabilities="^cap_net_bind_service,^cap_net_raw"
+           ;;
+       dhcp6|dhcp-ddns)
+           capabilities="^cap_net_bind_service"
+           ;;
+       ctrl-agent)
+           ;;
+       *)
+           eerror "KEA_SVC is undefined or invalid!"
+           eerror "It should be defined in /etc/conf.d/${RC_SVCNAME}"
+           return 1
+           ;;
+       esac
+}
+
+checkconfig() {
+       ${command} -t ${KEA_CONFIG} 1>/dev/null 2>/dev/null || return 1
+}
+
+reload() {
+       checkconfig || return 1
+       ebegin "Reloading ${RC_SVCNAME}"
+       start-stop-daemon --signal HUP --pidfile ${pidfile}
+       eend $?
+}
+
+start_pre() {
+       check_kea_svc || return 1
+
+       if [ $(stat -c "%U:%G" ${KEA_CONFIG}) != "root:${KEA_GROUP}" ] ; then
+               eerror "${KEA_CONFIG} config file is not owned by 
root:${KEA_GROUP}"
+               eerror "you should reset the ownership:"
+               eerror "chown root:${KEA_GROUP} ${KEA_CONFIG}"
+               return 1
+       fi
+
+       if [ "${RC_CMD}" != "restart" ]; then
+               checkconfig || return 1
+       fi
+}
+
+stop_pre() {
+       if [ "${RC_CMD}" != "restart" ]; then
+               checkconfig || return 1
+       fi
+}

diff --git a/net-misc/kea/kea-3.0.0.ebuild b/net-misc/kea/kea-3.0.0.ebuild
index 182dbd12d0d8..bed33f18bcb4 100644
--- a/net-misc/kea/kea-3.0.0.ebuild
+++ b/net-misc/kea/kea-3.0.0.ebuild
@@ -9,7 +9,7 @@ inherit eapi9-ver flag-o-matic meson python-r1 systemd tmpfiles 
toolchain-funcs
 DESCRIPTION="High-performance production grade DHCPv4 & DHCPv6 server"
 HOMEPAGE="https://www.isc.org/kea/";
 
-if [[ ${PV} == *9999* ]]; then
+if [[ ${PV} == 9999 ]]; then
        inherit git-r3
        EGIT_REPO_URI="https://gitlab.isc.org/isc-projects/kea.git";
 else
@@ -232,8 +232,15 @@ src_install() {
 
        fowners -R root:dhcp /etc/${PN}
 
-       newconfd "${FILESDIR}"/${PN}-confd-r2 ${PN}
-       newinitd "${FILESDIR}"/${PN}-initd-r2 ${PN}
+       # Install a conf per service and a linked init script per service
+       newinitd "${FILESDIR}"/${PN}-initd-r3 ${PN}
+       local svc
+       for svc in dhcp4 dhcp6 dhcp-ddns ctrl-agent; do
+               newconfd "${FILESDIR}"/${PN}-confd-r3 kea-${svc}
+               sed -e "s:@KEA_SVC@:${svc}:g" \
+                       -i "${ED}"/etc/conf.d/kea-${svc} || die
+               dosym kea "${EPREFIX}"/etc/init.d/kea-${svc}
+       done
 
        systemd_newunit "${FILESDIR}"/${PN}-ctrl-agent.service-r2 
${PN}-ctrl-agent.service
        systemd_newunit "${FILESDIR}"/${PN}-dhcp-ddns.service-r2 
${PN}-dhcp-ddns.service
@@ -264,6 +271,17 @@ pkg_postinst() {
                ewarn "Please check your configuration!"
        fi
 
+       if ver_replacing -lt 3.0; then
+               ewarn "If using openrc;"
+               ewarn "  There are now separate conf.d scripts and associated 
init.d per daemon!"
+               ewarn "    Each Daemon needs to be launched separately, i.e. 
the daemons are"
+               ewarn "      kea-dhcp4"
+               ewarn "      kea-dhcp6"
+               ewarn "      kea-dhcp-ddns"
+               ewarn "      kea-ctrl"
+               ewarn "Please adjust your service startups appropriately"
+       fi
+
        if ! has_version net-misc/kea; then
                elog "See examples of config files in:"
                elog "  ${EROOT}/usr/share/doc/${PF}/examples"

Reply via email to