You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-misc/kea/files/kea-initd-r1

91 lines
2.2 KiB

#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
description="kea dhcp services"
dhcp4_command="/usr/sbin/kea-dhcp4"
dhcp6_command="/usr/sbin/kea-dhcp6"
ddns_command="/usr/sbin/kea-dhcp-ddns"
dhcp4_config="${DHCP4_CONFIG:-/etc/kea/dhcp4.conf}"
dhcp6_config="${DHCP6_CONFIG:-/etc/kea/dhcp6.conf}"
ddns_config="${DDNS_CONFIG:-/etc/kea/ddns.conf}"
dhcp4_pidfile="/run/kea-dhcp4.pid"
dhcp6_pidfile="/run/kea-dhcp6.pid"
ddns_pidfile="/run/kea-ddns.pid"
depend() {
use net
}
start_pre() {
if ${DHCP4:-false} ; then
if [ ! -f "${dhcp4_config}" ] ; then
eerror "Please create a ${dhcp4_config} config file."
return 1
fi
if ! ${dhcp4_command} -t ${dhcp4_config} 1>/dev/null 2>/dev/null ; then
eerror "Error in config file ${dhcp4_config}"
return 1
fi
fi
if ${DHCP6:-false} ; then
if [ ! -f "${dhcp6_config}" ] ; then
eerror "Please create a ${dhcp6_file} config file."
return 1
fi
if ! ${dhcp6_command} -t ${dhcp6_config} 1>/dev/null 2>/dev/null ; then
eerror "Error in config file ${dhcp6_config}"
return 1
fi
fi
if ${DDNS:-false} ; then
if [ ! -f "${ddns_config}" ] ; then
eerror "Please create a ${ddns_config} config file."
return 1
fi
if ! ${ddns_command} -t ${ddns_config} 1>/dev/null 2>/dev/null ; then
eerror "Error in config file ${ddns_config}"
return 1
fi
fi
}
start() {
einfo "Starting kea dhcp services"
if ${DHCP4:-false} ; then
start-stop-daemon -m -b -p ${dhcp4_pidfile} \
-x ${dhcp4_command} -- -c ${dhcp4_config} \
|| return 1
fi
if ${DHCP6:-false} ; then
start-stop-daemon -m -b -p ${dhcp6_pidfile} \
-x ${dhcp6_command} -- -c ${dhcp6_config} \
|| return 1
fi
if ${DDNS:-false} ; then
start-stop-daemon -m -b -p ${ddns_pidfile} \
-x ${ddns_command} -- -c ${ddns_config} \
|| return 1
fi
}
stop() {
einfo "Stopping kea dhcp services"
if ${DHCP4:-false} ; then
start-stop-daemon --stop -p ${dhcp4_pidfile} \
|| return 1
fi
if ${DHCP6:-false} ; then
start-stop-daemon --stop -p ${dhcp6_pidfile} \
|| return 1
fi
if ${DDNS:-false} ; then
start-stop-daemon --stop -p ${ddns_pidfile} \
|| return 1
fi
}