2019-03-05 11:45:47 +01:00
|
|
|
|
#!/sbin/openrc-run
|
2021-04-10 11:09:56 +02:00
|
|
|
|
# Copyright 1999-2021 Gentoo Authors
|
2019-03-05 17:22:21 +01:00
|
|
|
|
# Copyright 2019 Alarig Le Lay <alarig@grifon.fr>
|
2019-03-05 11:45:47 +01:00
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
|
|
|
|
|
extra_started_commands="reload"
|
|
|
|
|
|
2019-03-05 17:08:15 +01:00
|
|
|
|
pidfile="/run/${RC_SVCNAME}.pid"
|
|
|
|
|
command="/usr/sbin/${RC_SVCNAME}"
|
|
|
|
|
retry=15
|
2020-04-22 13:13:06 +02:00
|
|
|
|
start_stop_daemon_args="--make-pidfile"
|
2019-03-05 17:08:15 +01:00
|
|
|
|
|
2019-03-05 11:45:47 +01:00
|
|
|
|
CONF_FILE="/etc/${RC_SVCNAME}.conf"
|
2019-03-05 17:08:15 +01:00
|
|
|
|
SOCK="/run/${RC_SVCNAME}.ctl"
|
2019-03-05 11:45:47 +01:00
|
|
|
|
|
2020-04-12 14:48:22 +02:00
|
|
|
|
if [ ${BIRD_GROUP} ]; then
|
|
|
|
|
BIRD_OPTS="${BIRD_OPTS} -g ${BIRD_GROUP}"
|
|
|
|
|
fi
|
|
|
|
|
if [ ${BIRD_USER} ]; then
|
|
|
|
|
BIRD_OPTS="${BIRD_OPTS} -u ${BIRD_USER}"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-03-05 17:08:15 +01:00
|
|
|
|
client_args="-s ${SOCK}"
|
2020-04-22 13:31:40 +02:00
|
|
|
|
command_args="${client_args} -c ${CONF_FILE} -P ${pidfile} ${BIRD_OPTS}"
|
2019-03-05 17:08:15 +01:00
|
|
|
|
client_args="${client_args} -r"
|
2019-03-05 11:45:47 +01:00
|
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
|
need net
|
|
|
|
|
use logger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_run() {
|
2019-03-06 10:51:42 +01:00
|
|
|
|
BIRD_CHECK_CONF="birdc ${client_args} configure check \"${CONF_FILE}\""
|
2019-03-05 12:02:14 +01:00
|
|
|
|
# Check if the bird parser returns what we want
|
|
|
|
|
# We can’t use $? because it’s always 0 if the sock works
|
2019-03-05 17:08:15 +01:00
|
|
|
|
STATE=$(${BIRD_CHECK_CONF} | grep 'Configuration OK')
|
2019-03-05 11:45:47 +01:00
|
|
|
|
|
|
|
|
|
if [ -n "${STATE}" ]; then
|
|
|
|
|
return 0
|
|
|
|
|
else
|
2019-03-05 17:08:15 +01:00
|
|
|
|
# We remove the first three lines (garbage informations), the
|
|
|
|
|
# errors begin after that
|
|
|
|
|
eerror "$(${BIRD_CHECK_CONF} | sed '1,3d')"
|
2019-03-05 11:45:47 +01:00
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
|
check_run || return 1
|
|
|
|
|
ebegin "Reloading BIRD"
|
2019-03-05 14:19:34 +01:00
|
|
|
|
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
2019-03-05 11:45:47 +01:00
|
|
|
|
eend $?
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-22 13:31:40 +02:00
|
|
|
|
start_post() {
|
|
|
|
|
checkpath -f -m 0655 -o bird:bird "${pidfile}"
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-05 11:45:47 +01:00
|
|
|
|
stop_pre() {
|
|
|
|
|
if [ "${RC_CMD}" = "restart" ] ; then
|
|
|
|
|
check_run || return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|