SwordArMor-gentoo-overlay/net-misc/bird/files/initd-bird-2
Alarig Le Lay 1ee2322e81
net-misc/bird: Init improvement for non-root usage
Package-Manager: Portage-3.0.20, Repoman-3.0.2
Signed-off-by: Alarig Le Lay <alarig@swordarmor.fr
2021-08-05 16:27:40 +02:00

67 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Copyright 2019 Alarig Le Lay <alarig@grifon.fr>
# Distributed under the terms of the GNU General Public License v2
extra_started_commands="reload"
pidfile="/run/${RC_SVCNAME}/${RC_SVCNAME}.pid"
command="/usr/sbin/${RC_SVCNAME}"
retry=15
CONF_FILE="/etc/${RC_SVCNAME}.conf"
SOCK="/run/${RC_SVCNAME}/${RC_SVCNAME}.ctl"
if [ ${BIRD_GROUP} ]; then
BIRD_OPTS="${BIRD_OPTS} -g ${BIRD_GROUP}"
fi
if [ ${BIRD_USER} ]; then
BIRD_OPTS="${BIRD_OPTS} -u ${BIRD_USER}"
fi
client_args="-s ${SOCK}"
command_args="${client_args} -c ${CONF_FILE} -P ${pidfile} ${BIRD_OPTS}"
client_args="${client_args} -r"
depend() {
use net
use logger
}
check_run() {
BIRD_CHECK_CONF="birdc ${client_args} configure check \"${CONF_FILE}\""
# Check if the bird parser returns what we want
# We cant use $? because its always 0 if the sock works
STATE=$(${BIRD_CHECK_CONF} | grep 'Configuration OK')
if [ -n "${STATE}" ]; then
return 0
else
# We remove the first three lines (garbage informations), the
# errors begin after that
eerror "$(${BIRD_CHECK_CONF} | sed '1,3d')"
return 1
fi
}
reload() {
check_run || return 1
ebegin "Reloading BIRD"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
start_pre() {
checkpath -d -m 0755 -o bird:bird "/run/${RC_SVCNAME}"
}
start_post() {
ln -sf "${SOCK}" /run
}
stop_pre() {
if [ "${RC_CMD}" = "restart" ] ; then
check_run || return 1
fi
}