kea: add kea-uci package with basic init script 16296/head
authorStijn Tintel <stijn@linux-ipv6.be>
Thu, 5 Aug 2021 19:26:20 +0000 (22:26 +0300)
committerStijn Tintel <stijn@linux-ipv6.be>
Mon, 16 Aug 2021 17:41:51 +0000 (20:41 +0300)
This init script allows to start the Kea Control Agent, the DHCPv4
server, the DHCPv6 server, and the DHCP-DDNS server. It expects the
config files to be where the packages install them.

As this is a single init script that can start 4 different binaries that
are each in their own package, these files cannot be included in any of
these other package, so create a dedicated package for it.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
net/kea/Makefile
net/kea/files/kea.config [new file with mode: 0644]
net/kea/files/kea.init [new file with mode: 0755]

index 9e7796692c6b3e04226f7d591aa5efa73af5dd71..f0def030b147f5ce2447d6dd3010fc8809b88142 100644 (file)
@@ -182,6 +182,17 @@ define Package/kea-shell/description
 Control Agent.
 endef
 
+###### *************************************************************************
+define Package/kea-uci
+       $(call Package/kea/Default)
+       TITLE+=UCI support
+       DEPENDS:=@(PACKAGE_kea-ctrl||PACKAGE_kea-dhcp4||PACKAGE_kea-dhcp6||PACKAGE_kea-dhcp-ddns)
+endef
+define Package/kea-uci/description
+       Kea PROCD/UCI support. This package installs a UCI config file and
+       a PROCD service file.
+endef
+
 ###### *************************************************************************
 HOST_CONFIGURE_ARGS += \
        --with-boost-include="$(STAGING_DIR_HOSTPKG)" \
@@ -296,6 +307,12 @@ define Package/kea-shell/install
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kea-shell $(1)/usr/sbin/kea-shell
 endef
 
+define Package/kea-uci/install
+       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
+       $(INSTALL_CONF) ./files/kea.config $(1)/etc/config/kea
+       $(INSTALL_BIN) ./files/kea.init $(1)/etc/init.d/kea
+endef
+
 $(eval $(call HostBuild))
 $(eval $(call BuildPackage,kea-libs))
 $(eval $(call BuildPackage,kea-ctrl))
@@ -308,3 +325,4 @@ $(eval $(call BuildPackage,kea-hook-lease-cmds))
 $(eval $(call BuildPackage,kea-lfc))
 $(eval $(call BuildPackage,kea-perfdhcp))
 $(eval $(call BuildPackage,kea-shell))
+$(eval $(call BuildPackage,kea-uci))
diff --git a/net/kea/files/kea.config b/net/kea/files/kea.config
new file mode 100644 (file)
index 0000000..9edd655
--- /dev/null
@@ -0,0 +1,11 @@
+config service 'ctrl_agent'
+       option disabled '1'
+
+config service 'dhcp4'
+       option disabled '1'
+
+config service 'dhcp6'
+       option disabled '1'
+
+config service 'dhcp_ddns'
+       option disabled '1'
diff --git a/net/kea/files/kea.init b/net/kea/files/kea.init
new file mode 100755 (executable)
index 0000000..ee4bf88
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+START=25
+STOP=85
+
+BIN_PATH="/usr/sbin"
+CONF_PATH="/etc/kea"
+
+start_service() {
+       config_load "kea"
+       config_foreach start_kea "service"
+}
+
+start_kea() {
+       local cfg="$1"
+
+       config_get_bool disabled "$cfg" disabled 0
+       [ "$disabled" = "0" ] || return
+
+       config_get name "$cfg" name "$cfg"
+
+       case "$name" in
+               ctrl_agent|dhcp4|dhcp6|dhcp_ddns)
+                       name="${name/_/-}"
+                       cmd="${BIN_PATH}/kea-${name}"
+                       cnf="${CONF_PATH}/kea-${name}.conf"
+                       ;;
+               *)
+                       return 0
+       esac
+
+       procd_open_instance "$name"
+       procd_set_param command "$cmd" -c "$cnf"
+       procd_set_param env KEA_LOCKFILE_DIR=/tmp
+       procd_append_param env KEA_PIDFILE_DIR=/tmp
+       procd_set_param file "$cnf"
+       procd_set_param stderr 1
+       procd_set_param stdout 1
+       procd_close_instance ctrl_agent
+}