2019-03-05 11:45:47 +01:00
|
|
|
|
#!/sbin/openrc-run
|
|
|
|
|
# Copyright 1999-2012 Gentoo Foundation
|
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
|
|
|
|
|
extra_started_commands="reload"
|
|
|
|
|
|
|
|
|
|
pidfile="/var/run/${RC_SVCNAME}.pid"
|
|
|
|
|
CONF_FILE="/etc/${RC_SVCNAME}.conf"
|
|
|
|
|
SOCK="/var/run/${RC_SVCNAME}.ctl"
|
|
|
|
|
|
|
|
|
|
command="/usr/sbin/${RC_SVCNAME}"
|
|
|
|
|
command_args="-c ${CONF_FILE} -s ${SOCK} -P ${pidfile}"
|
|
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
|
need net
|
|
|
|
|
use logger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkconfig() {
|
|
|
|
|
if [ ! -f "CONF_FILE" ]; then
|
|
|
|
|
eerror "Please create ${CONF_FILE}"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_run() {
|
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
|
|
|
|
|
STATE=$(birdc -s ${SOCK} 'configure check' | \
|
2019-03-05 11:45:47 +01:00
|
|
|
|
grep 'Configuration OK')
|
|
|
|
|
|
|
|
|
|
if [ -n "${STATE}" ]; then
|
|
|
|
|
return 0
|
|
|
|
|
else
|
2019-03-05 12:02:14 +01:00
|
|
|
|
# We remove the first two lines (garbage informations), the
|
|
|
|
|
# errors begin at the third
|
|
|
|
|
eerror "$(birdc -s ${SOCK} 'configure check' | \
|
2019-03-05 11:45:47 +01:00
|
|
|
|
sed '1d;2d')"
|
|
|
|
|
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 $?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stop_pre() {
|
|
|
|
|
if [ "${RC_CMD}" = "restart" ] ; then
|
|
|
|
|
check_run || return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
|
ebegin "Stopping BIRD"
|
|
|
|
|
start-stop-daemon --stop --exec ${command} --retry 15
|
|
|
|
|
}
|