Files
packages/net/kea/files/kea.init
Philip Prindeville 2a85ed0f1d kea: add support synthesizing imported config files
Configuring Kea JSON files is not trivial, and this might impede
the adoption of Kea as a DHCP server.  There are, however, many
users who used its predecessor ISC-DHCP, at least for DHCPv4.
A filter could ingest the legacy UCI and synthesize a JSON config
file for Kea DHCPv4.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2026-04-09 17:36:46 -06:00

57 lines
1.1 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=25
STOP=85
LIB_PATH="/usr/lib/kea"
BIN_PATH="/usr/sbin"
CONF_PATH="/etc/kea"
start_service() {
mkdir --mode=0750 -p /var/lib/kea /var/run/kea
config_load "kea"
config_foreach start_kea "service"
}
start_kea() {
local cfg="$1"
local name cmd cnf importer
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)
;;
*)
echo "Error: Invalid service name '$name'" >&2
return 1
;;
esac
name="${name/_/-}"
cmd="${BIN_PATH}/kea-${name}"
cnf="${CONF_PATH}/kea-${name}.conf"
importer="${LIB_PATH}/importers/${name}.sh"
if [ -f "$importer" ]; then
if ! "$importer" "$cnf"; then
echo "Error: Importer '$importer' failed; aborting." >&2
return 1
fi
fi
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
}