5 # Required-Start: $local_fs $network $remote_fs $syslog
6 # Required-Stop: $local_fs $network $remote_fs $syslog
7 # Default-Start: 2 3 4 5
9 # Short-Description: start and stop the FRR routing suite
10 # Description: FRR is a routing suite for IP routing protocols like
11 # BGP, OSPF, RIP and others. This script contols the main
15 # This is the main init script for FRR. It mostly wraps frrcommon.sh which
16 # provides the actual functions to start/stop/restart things.
19 if [ -r "/lib/lsb/init-functions" ]; then
20 .
/lib
/lsb
/init-functions
33 # "/usr/lib/frr/frrinit.sh start somenamespace"
37 if [ -r "$self/frrcommon.sh" ]; then
38 .
"$self/frrcommon.sh"
40 .
"@CFG_SBIN@/frrcommon.sh"
46 watchfrr_options
="$watchfrr_options $daemons"
52 exit ${still_running:-0}
60 watchfrr_options
="$watchfrr_options $daemons"
66 print_status watchfrr || fail
=1
72 if [ ! -x "$RELOAD_SCRIPT" ]; then
73 log_failure_msg
"The frr-pythontools package is required for reload functionality."
77 # systemd doesn't set WATCHDOG_USEC for reload commands.
78 watchfrr_pidfile
="$V_PATH/watchfrr.pid"
79 watchfrr_pid
="`cat \"$watchfrr_pidfile\"`"
80 if [ -d "/proc/$watchfrr_pid" ]; then
81 wdt
="`tr '\0' '\n' < /proc/$watchfrr_pid/environ | grep '^WATCHDOG_USEC='`"
82 wdt
="${wdt#WATCHDOG_USEC=}"
83 [ -n "$wdt" ] && : ${WATCHDOG_USEC:=$wdt}
84 [ -n "$WATCHDOG_USEC" ] && export WATCHDOG_USEC
87 # restart watchfrr to pick up added daemons.
88 # NB: This will NOT cause the other daemons to be restarted.
90 watchfrr_options
="$watchfrr_options $daemons"
91 daemon_stop watchfrr
&& \
94 # make systemd not kill watchfrr after ExecReload completes
95 # 3 goats were sacrificed to restore sanity after coding this
96 watchfrr_pid
="`cat \"$watchfrr_pidfile\"`"
97 if [ -f "/proc/$watchfrr_pid/cgroup" -a -d "/sys/fs/cgroup/systemd" ]; then
98 cg
="`egrep '^[0-9]+:name=systemd:' \"/proc/$watchfrr_pid/cgroup\"`"
102 cgmain
="${cgmain%/.control}"
103 cgmain
="${cgmain%/control}"
105 [ -n "$cg" -a "$cg" != "$cgmain" ] && \
106 echo "$watchfrr_pid" > "/sys/fs/cgroup/systemd/$cgmain/tasks"
109 NEW_CONFIG_FILE
="${2:-$C_PATH/frr.conf}"
110 [ ! -r $NEW_CONFIG_FILE ] && log_failure_msg
"Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1
111 "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE" `echo $nsopt`
116 log_failure_msg
"Unknown command: $1" >&2