mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 22:50:14 +00:00
redhat: switch to new init script
Drop the special versions of frr.init/frr.service/daemons from redhat/ and use the generic versions instead. Tested-by: Liam McBirnie <liam.mcbirnie@boeing.com> Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
c1f026a7c4
commit
81b834a59d
@ -175,9 +175,6 @@ EXTRA_DIST += \
|
||||
python/clidef.py \
|
||||
python/clippy/__init__.py \
|
||||
\
|
||||
redhat/frr.init \
|
||||
redhat/frr.service \
|
||||
redhat/daemons \
|
||||
redhat/frr.logrotate \
|
||||
redhat/frr.pam \
|
||||
redhat/frr.spec \
|
||||
|
@ -1,86 +0,0 @@
|
||||
# This file tells the frr package which daemons to start.
|
||||
#
|
||||
# Entries are in the format: <daemon>=(yes|no|priority)
|
||||
# 0, "no" = disabled
|
||||
# 1, "yes" = highest priority
|
||||
# 2 .. 10 = lower priorities
|
||||
#
|
||||
# For daemons which support multiple instances, a 2nd line listing
|
||||
# the instances can be added. Eg for ospfd:
|
||||
# ospfd=yes
|
||||
# ospfd_instances="1,2"
|
||||
#
|
||||
# Priorities were suggested by Dancer <dancer@zeor.simegen.com>.
|
||||
# They're used to start the FRR daemons in more than one step
|
||||
# (for example start one or two at network initialization and the
|
||||
# rest later). The number of FRR daemons being small, priorities
|
||||
# must be between 1 and 9, inclusive (or the initscript has to be
|
||||
# changed). /etc/init.d/frr then can be started as
|
||||
#
|
||||
# /etc/init.d/frr <start|stop|restart|<priority>>
|
||||
#
|
||||
# where priority 0 is the same as 'stop', priority 10 or 'start'
|
||||
# means 'start all'
|
||||
#
|
||||
# Sample configurations for these daemons can be found in
|
||||
# /usr/share/doc/frr/examples/.
|
||||
#
|
||||
# ATTENTION:
|
||||
#
|
||||
# When activation a daemon at the first time, a config file, even if it is
|
||||
# empty, has to be present *and* be owned by the user and group "frr", else
|
||||
# the daemon will not be started by /etc/init.d/frr. The permissions should
|
||||
# be u=rw,g=r,o=.
|
||||
# When using "vtysh" such a config file is also needed. It should be owned by
|
||||
# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too.
|
||||
#
|
||||
watchfrr_enable=yes
|
||||
watchfrr_options="-r '/usr/lib/frr/frr restart %s' -s '/usr/lib/frr/frr start %s' -k '/usr/lib/frr/frr stop %s'"
|
||||
#
|
||||
zebra=no
|
||||
bgpd=no
|
||||
ospfd=no
|
||||
ospf6d=no
|
||||
ripd=no
|
||||
ripngd=no
|
||||
isisd=no
|
||||
ldpd=no
|
||||
pimd=no
|
||||
nhrpd=no
|
||||
eigrpd=no
|
||||
babeld=no
|
||||
sharpd=no
|
||||
pbrd=no
|
||||
staticd=no
|
||||
bfdd=no
|
||||
fabricd=no
|
||||
|
||||
#
|
||||
# Command line options for the daemons
|
||||
#
|
||||
zebra_options=("-A 127.0.0.1")
|
||||
bgpd_options=("-A 127.0.0.1")
|
||||
ospfd_options=("-A 127.0.0.1")
|
||||
ospf6d_options=("-A ::1")
|
||||
ripd_options=("-A 127.0.0.1")
|
||||
ripngd_options=("-A ::1")
|
||||
isisd_options=("-A 127.0.0.1")
|
||||
ldpd_options=("-A 127.0.0.1")
|
||||
pimd_options=("-A 127.0.0.1")
|
||||
nhrpd_options=("-A 127.0.0.1")
|
||||
eigrpd_options=("-A 127.0.0.1")
|
||||
babeld_options=("-A 127.0.0.1")
|
||||
sharpd_options=("-A 127.0.0.1")
|
||||
pbrd_options=("-A 127.0.0.1")
|
||||
staticd_options=("-A 127.0.0.1")
|
||||
bfdd_options=("-A 127.0.0.1")
|
||||
fabricd_options=("-A 127.0.0.1")
|
||||
|
||||
#
|
||||
# If the vtysh_enable is yes, then the unified config is read
|
||||
# and applied if it exists. If no unified frr.conf exists
|
||||
# then the per-daemon <daemon>.conf files are used)
|
||||
# If vtysh_enable is no or non-existant, the frr.conf is ignored.
|
||||
# it is highly suggested to have this set to yes
|
||||
vtysh_enable=yes
|
||||
|
577
redhat/frr.init
577
redhat/frr.init
@ -1,577 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/init.d/frr
|
||||
#
|
||||
# Start/Stop the FRR Routing daemons
|
||||
# <any general comments about this init script>
|
||||
#
|
||||
# chkconfig: 2345 15 85
|
||||
#
|
||||
# description: FRRouting (FRR) is a routing suite for IP routing protocols
|
||||
# like BGP, OSPF, RIP and others. This script contols the main
|
||||
# daemon "frr" as well as the individual protocol daemons.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: frr
|
||||
# Required-Start: $local_fs $network $syslog
|
||||
# Required-Stop: $local_fs $syslog
|
||||
# Should-Start: $syslog
|
||||
# Should-Stop: $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start/Stop the FRR Routing daemons
|
||||
# Description: FRRouting (FRR) is a routing suite for IP routing protocols
|
||||
# like BGP, OSPF, RIP and others. This script contols the main
|
||||
# daemon "frr" as well as the individual protocol daemons.
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
D_PATH=/usr/lib/frr
|
||||
C_PATH=/etc/frr
|
||||
V_PATH=/var/run/frr
|
||||
|
||||
# Local Daemon selection may be done by using /etc/frr/daemons.
|
||||
# See /usr/share/doc/frr/README.Debian.gz for further information.
|
||||
# Keep zebra first and do not list watchfrr!
|
||||
DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd pbrd ldpd nhrpd eigrpd babeld staticd sharpd bfdd fabricd"
|
||||
MAX_INSTANCES=5
|
||||
RELOAD_SCRIPT=/usr/lib/frr/frr-reload.py
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
# Print the name of the pidfile.
|
||||
pidfile()
|
||||
{
|
||||
echo "$V_PATH/$1.pid"
|
||||
}
|
||||
|
||||
# Print the name of the vtysh.
|
||||
vtyfile()
|
||||
{
|
||||
echo "$V_PATH/$1.vty"
|
||||
}
|
||||
|
||||
# Check if daemon is started by using the pidfile.
|
||||
started()
|
||||
{
|
||||
[ ! -e `pidfile $1` ] && return 3
|
||||
if [ -n "$2" ] && [ "$2" == "log" ]; then
|
||||
status -p `pidfile $1` $1 && return 0 || return $?
|
||||
else
|
||||
kill -0 `cat \`pidfile $1\`` 2> /dev/null || return 1
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Loads the config via vtysh -b if configured to do so.
|
||||
vtysh_b ()
|
||||
{
|
||||
# Rember, that all variables have been incremented by 1 in convert_daemon_prios()
|
||||
if [ "$vtysh_enable" = 2 -a -f $C_PATH/frr.conf ]; then
|
||||
/usr/bin/vtysh -b -n
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if the daemon is activated and if its executable and config files
|
||||
# are in place.
|
||||
# params: daemon name
|
||||
# returns: 0=ok, 1=error
|
||||
check_daemon()
|
||||
{
|
||||
# If the integrated config file is used the others are not checked.
|
||||
if [ -r "$C_PATH/frr.conf" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# vtysh_enable has no config file nor binary so skip check.
|
||||
# (Not sure why vtysh_enable is in this list but does not hurt)
|
||||
if [ $1 != "watchfrr" -a $1 != "vtysh_enable" ]; then
|
||||
# check for daemon binary
|
||||
if [ ! -x "$D_PATH/$1" ]; then return 1; fi
|
||||
|
||||
# check for config file
|
||||
if [ -n "$2" ]; then
|
||||
if [ ! -r "$C_PATH/$1-$2.conf" ]; then
|
||||
touch "$C_PATH/$1-$2.conf"
|
||||
chown frr:frr "$C_PATH/$1-$2.conf"
|
||||
fi
|
||||
elif [ ! -r "$C_PATH/$1.conf" ]; then
|
||||
touch "$C_PATH/$1.conf"
|
||||
chown frr:frr "$C_PATH/$1.conf"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Starts the server if it's not already running according to the pid file.
|
||||
# The Frr daemons creates the pidfile when starting.
|
||||
start()
|
||||
{
|
||||
local dmn inst
|
||||
dmn="$1"
|
||||
inst="$2"
|
||||
|
||||
ulimit -n $MAX_FDS > /dev/null 2> /dev/null
|
||||
if [ "$dmn" = "watchfrr" ]; then
|
||||
|
||||
# We may need to restart watchfrr if new daemons are added and/or
|
||||
# removed
|
||||
if started "$dmn" ; then
|
||||
stop watchfrr
|
||||
else
|
||||
# Echo only once. watchfrr is printed in the stop above
|
||||
echo -n " $dmn"
|
||||
fi
|
||||
|
||||
if [ -e /var/run/frr/watchfrr.started ] ; then
|
||||
rm /var/run/frr/watchfrr.started
|
||||
fi
|
||||
# redhat /etc/init.d/functions daemon() re-expands args :(
|
||||
# eval "set - $watchfrr_options"
|
||||
daemon --pidfile=`pidfile $dmn` "$D_PATH/$dmn" -d "$watchfrr_options"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -ne 0 ] && break
|
||||
for i in `seq 1 10`;
|
||||
do
|
||||
if [ -e /var/run/frr/watchfrr.started ] ; then
|
||||
RETVAL=0
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
RETVAL=1
|
||||
elif [ -n "$inst" ]; then
|
||||
echo -n " $dmn-$inst"
|
||||
if ! check_daemon $dmn $inst ; then
|
||||
echo -n " (binary does not exist)"
|
||||
return;
|
||||
fi
|
||||
daemon --pidfile=`pidfile $dmn-$inst` "$D_PATH/$dmn" -d `eval echo "$""$dmn""_options"` -n "$inst"
|
||||
RETVAL=$?
|
||||
else
|
||||
echo -n " $dmn "
|
||||
if ! check_daemon $dmn; then
|
||||
echo " (binary does not exist)"
|
||||
return;
|
||||
fi
|
||||
daemon --pidfile=`pidfile $dmn` "$D_PATH/$dmn" -d `eval echo "$""$dmn""_options"`
|
||||
RETVAL=$?
|
||||
fi
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$dmn
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# Stop the daemon given in the parameter, printing its name to the terminal.
|
||||
stop()
|
||||
{
|
||||
local inst
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
inst="$1-$2"
|
||||
else
|
||||
inst="$1"
|
||||
fi
|
||||
|
||||
if ! started "$inst" ; then
|
||||
# echo -n " ($inst)"
|
||||
return 0
|
||||
else
|
||||
echo -n " $inst"
|
||||
PIDFILE=`pidfile $inst`
|
||||
PID=`cat $PIDFILE 2>/dev/null`
|
||||
killproc -p "$PIDFILE" "$D_PATH/$1"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
||||
rm -f `pidfile $inst`
|
||||
rm -f `vtyfile $inst`
|
||||
echo
|
||||
return $RETVAL
|
||||
fi
|
||||
}
|
||||
|
||||
# Converts values from /etc/frr/daemons to all-numeric values.
|
||||
convert_daemon_prios()
|
||||
{
|
||||
for name in $DAEMONS zebra vtysh_enable watchfrr_enable; do
|
||||
# First, assign the value set by the user to $value
|
||||
eval value=\${${name}:0:3}
|
||||
|
||||
# Daemon not activated or entry missing?
|
||||
if [ "$value" = "no" -o "$value" = "" ]; then value=0; fi
|
||||
|
||||
# These strings parsed for backwards compatibility.
|
||||
if [ "$value" = "yes" -o "$value" = "true" ]; then
|
||||
value=1;
|
||||
fi
|
||||
|
||||
# Zebra is threatened special. It must be between 0=off and the first
|
||||
# user assigned value "1" so we increase all other enabled daemons' values.
|
||||
if [ "$name" != "zebra" -a "$value" -gt 0 ]; then value=`expr "$value" + 1`; fi
|
||||
|
||||
# If e.g. name is zebra then we set "zebra=yes".
|
||||
eval $name=$value
|
||||
done
|
||||
}
|
||||
|
||||
# Starts watchfrr for all wanted daemons.
|
||||
start_watchfrr()
|
||||
{
|
||||
local daemon_name
|
||||
local daemon_prio
|
||||
local found_one
|
||||
local daemon_inst
|
||||
|
||||
# Start the monitor daemon only if desired.
|
||||
if [ 0 -eq "$watchfrr_enable" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Check variable type
|
||||
if declare -p watchfrr_options | grep -q '^declare \-a'; then
|
||||
# old array support
|
||||
watchfrr_options="${watchfrr_options[@]}"
|
||||
fi
|
||||
|
||||
# Which daemons have been started?
|
||||
found_one=0
|
||||
for daemon_name in $DAEMONS; do
|
||||
eval daemon_prio=\$$daemon_name
|
||||
if [ "$daemon_prio" -gt 0 ]; then
|
||||
eval "daemon_inst=\${${daemon_name}_instances//,/ }"
|
||||
if [ -n "$daemon_inst" ]; then
|
||||
for inst in ${daemon_inst}; do
|
||||
eval "inst_disable=\${${daemon_name}_${inst}}"
|
||||
if [ -z ${inst_disable} ] || [ ${inst_disable} != 0 ]; then
|
||||
if check_daemon $daemon_name $inst; then
|
||||
watchfrr_options="$watchfrr_options ${daemon_name}-${inst}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
if check_daemon $daemon_name; then
|
||||
watchfrr_options="$watchfrr_options $daemon_name"
|
||||
fi
|
||||
fi
|
||||
found_one=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Start if at least one daemon is activated.
|
||||
if [ $found_one -eq 1 ]; then
|
||||
echo "Starting FRRouting monitor daemon:"
|
||||
start watchfrr
|
||||
fi
|
||||
}
|
||||
|
||||
# Stopps watchfrr.
|
||||
stop_watchfrr()
|
||||
{
|
||||
echo "Stopping FRRouting monitor daemon:"
|
||||
stop watchfrr
|
||||
}
|
||||
|
||||
# Stops all daemons that have a lower level of priority than the given.
|
||||
# (technically if daemon_prio >= wanted_prio)
|
||||
stop_prio()
|
||||
{
|
||||
local wanted_prio
|
||||
local daemon_prio
|
||||
local daemon_list
|
||||
local daemon_inst
|
||||
local inst
|
||||
|
||||
if [ -n "$2" ] && [[ "$2" =~ (.*)-(.*) ]]; then
|
||||
daemon=${BASH_REMATCH[1]}
|
||||
inst=${BASH_REMATCH[2]}
|
||||
else
|
||||
daemon="$2"
|
||||
fi
|
||||
|
||||
wanted_prio=$1
|
||||
daemon_list=${daemon:-$DAEMONS}
|
||||
|
||||
echo "Stopping FRRouting daemons (prio:$wanted_prio):"
|
||||
|
||||
for prio_i in `seq 10 -1 $wanted_prio`; do
|
||||
for daemon_name in $daemon_list; do
|
||||
eval daemon_prio=\${${daemon_name}:0:3}
|
||||
daemon_inst=""
|
||||
if [ $daemon_prio -eq $prio_i ]; then
|
||||
eval "daemon_inst=\${${daemon_name}_instances//,/ }"
|
||||
if [ -n "$daemon_inst" ]; then
|
||||
for i in ${daemon_inst}; do
|
||||
if [ -n "$inst" ] && [ "$i" == "$inst" ]; then
|
||||
stop "$daemon_name" "$inst"
|
||||
elif [ x"$inst" == x ]; then
|
||||
stop "$daemon_name" "$i"
|
||||
fi
|
||||
done
|
||||
else
|
||||
stop "$daemon_name"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ -z "$inst" ]; then
|
||||
# Now stop other daemons that're prowling, coz the daemons file changed
|
||||
echo "Stopping other FRRouting daemons"
|
||||
if [ -n "$daemon" ]; then
|
||||
eval "file_list_suffix="$V_PATH"/"$daemon*""
|
||||
else
|
||||
eval "file_list_suffix="$V_PATH/*""
|
||||
fi
|
||||
for pidfile in $file_list_suffix.pid; do
|
||||
if [ -f "$pidfile" ]; then
|
||||
filename=${pidfile##*/}
|
||||
daemon=${filename%.*}
|
||||
echo -n " $daemon"
|
||||
killproc -p "$pidfile" "$daemon"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
||||
rm -f "$pidfile"
|
||||
echo
|
||||
fi
|
||||
done
|
||||
echo -n "Removing remaining .vty files"
|
||||
for vtyfile in $file_list_suffix.vty; do
|
||||
rm -rf "$vtyfile"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Starts all daemons that have a higher level of priority than the given.
|
||||
# (technically if daemon_prio <= wanted_prio)
|
||||
start_prio()
|
||||
{
|
||||
local wanted_prio
|
||||
local daemon_prio
|
||||
local daemon_list
|
||||
local daemon_name
|
||||
local daemon_inst
|
||||
local inst
|
||||
|
||||
if [ -n "$2" ] && [[ "$2" =~ (.*)-(.*) ]]; then
|
||||
daemon=${BASH_REMATCH[1]}
|
||||
inst=${BASH_REMATCH[2]}
|
||||
else
|
||||
daemon="$2"
|
||||
fi
|
||||
|
||||
wanted_prio=$1
|
||||
daemon_list=${daemon:-$DAEMONS}
|
||||
|
||||
echo "Starting FRRouting daemons (prio:$wanted_prio):"
|
||||
|
||||
for prio_i in `seq 1 $wanted_prio`; do
|
||||
for daemon_name in $daemon_list; do
|
||||
eval daemon_prio=\$${daemon_name}
|
||||
daemon_inst=""
|
||||
if [ $daemon_prio -eq $prio_i ]; then
|
||||
eval "daemon_inst=\${${daemon_name}_instances//,/ }"
|
||||
if [ -n "$daemon_inst" ]; then
|
||||
if [ `echo "$daemon_inst" | wc -w` -gt ${MAX_INSTANCES} ]; then
|
||||
echo "Max instances supported is ${MAX_INSTANCES}. Aborting"
|
||||
exit 1
|
||||
fi
|
||||
# Check if we're starting again by switching from single instance
|
||||
# to MI version
|
||||
if started "$daemon_name"; then
|
||||
PIDFILE=`pidfile $daemon_name`
|
||||
killproc -p "$PIDFILE" "$daemon_name"
|
||||
rm -f `pidfile $1`
|
||||
rm -f `vtyfile $1`
|
||||
fi
|
||||
|
||||
for i in ${daemon_inst}; do
|
||||
if [ -n "$inst" ] && [ "$i" == "$inst" ]; then
|
||||
start "$daemon_name" "$inst"
|
||||
elif [ x"$inst" == x ]; then
|
||||
start "$daemon_name" "$i"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Check if we're starting again by switching from
|
||||
# single instance to MI version
|
||||
eval "file_list_suffix="$V_PATH"/"$daemon_name-*""
|
||||
for pidfile in $file_list_suffix.pid; do
|
||||
if [ -f "$pidfile" ]; then
|
||||
killproc -p "$pidfile" "$daemon_name"
|
||||
rm -rf "$pidfile"
|
||||
fi
|
||||
done
|
||||
for vtyfile in $file_list_suffix.vty; do
|
||||
rm -rf "$vtyfile"
|
||||
done
|
||||
|
||||
start "$daemon_name"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
check_status()
|
||||
{
|
||||
local daemon_name
|
||||
local daemon_prio
|
||||
local daemon_inst
|
||||
local failed_status=0
|
||||
|
||||
if [ -n "$1" ] && [[ "$1" =~ (.*)-(.*) ]]; then
|
||||
daemon=${BASH_REMATCH[1]}
|
||||
inst=${BASH_REMATCH[2]}
|
||||
else
|
||||
daemon="$1"
|
||||
fi
|
||||
|
||||
daemon_list=${daemon:-$DAEMONS}
|
||||
|
||||
# Which daemons have been started?
|
||||
for daemon_name in $daemon_list; do
|
||||
eval daemon_prio=\$$daemon_name
|
||||
if [ "$daemon_prio" -gt 0 ]; then
|
||||
eval "daemon_inst=\${${daemon_name}_instances//,/ }"
|
||||
if [ -n "$daemon_inst" ]; then
|
||||
for i in ${daemon_inst}; do
|
||||
if [ -n "$inst" -a "$inst" = "$i" ]; then
|
||||
started "$1" "log" || failed_status=$?
|
||||
elif [ -z "$inst" ]; then
|
||||
started "$daemon_name-$i" "log" || failed_status=$?
|
||||
fi
|
||||
done
|
||||
else
|
||||
started "$daemon_name" "log" || failed_status=$?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# All daemons that need to have been started are up and running
|
||||
return $failed_status
|
||||
}
|
||||
|
||||
#########################################################
|
||||
# Main program #
|
||||
#########################################################
|
||||
|
||||
# Config broken but script must exit silently.
|
||||
[ ! -r "$C_PATH/daemons" ] && exit 0
|
||||
|
||||
# Load configuration
|
||||
. "$C_PATH/daemons"
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/sysconfig/frr ] && . /etc/sysconfig/frr
|
||||
|
||||
MAX_INSTANCES=${MAX_INSTANCES:=5}
|
||||
|
||||
# Set priority of un-startable daemons to 'no' and substitute 'yes' to '0'
|
||||
convert_daemon_prios
|
||||
|
||||
if [ ! -d $V_PATH ]; then
|
||||
echo "Creating $V_PATH"
|
||||
mkdir -p $V_PATH
|
||||
chown frr:frr $V_PATH
|
||||
chmod 755 /$V_PATH
|
||||
fi
|
||||
|
||||
if [ -n "$3" ] && [ "$3" != "all" ]; then
|
||||
dmn="$2"-"$3"
|
||||
elif [ -n "$2" ] && [ "$2" != "all" ]; then
|
||||
dmn="$2"
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
# Try to load this necessary (at least for 2.6) module.
|
||||
if [ -d /lib/modules/`uname -r` ] ; then
|
||||
echo "Loading capability module if not yet done."
|
||||
LC_ALL=C modprobe -a capability 2>&1 | egrep -v "(not found|Can't locate)"
|
||||
fi
|
||||
|
||||
# Start all daemons
|
||||
cd $C_PATH/
|
||||
if [ "$2" != "watchfrr" ]; then
|
||||
start_prio 10 $dmn
|
||||
fi
|
||||
start_watchfrr
|
||||
vtysh_b
|
||||
;;
|
||||
|
||||
1|2|3|4|5|6|7|8|9|10)
|
||||
# Stop/start daemons for the appropriate priority level
|
||||
stop_prio $1
|
||||
start_prio $1
|
||||
vtysh_b
|
||||
;;
|
||||
|
||||
stop|0)
|
||||
# Stop all daemons at level '0' or 'stop'
|
||||
stop_watchfrr
|
||||
if [ "$dmn" != "watchfrr" ]; then
|
||||
[ -n "${dmn}" ] && eval "${dmn/-/_}=0"
|
||||
stop_prio 0 $dmn
|
||||
fi
|
||||
|
||||
if [ -z "$dmn" -o "$dmn" = "zebra" ]; then
|
||||
echo "Removing all routes made by zebra."
|
||||
ip route flush proto zebra
|
||||
# At least in CentOS/RHEL 6, iproute2 doesn't know
|
||||
# about the new protocol names, so we have to flush them
|
||||
# by number (it also doesn't support rt_protos.d
|
||||
ip route flush proto 186
|
||||
ip route flush proto 187
|
||||
ip route flush proto 188
|
||||
ip route flush proto 189
|
||||
ip route flush proto 190
|
||||
ip route flush proto 191
|
||||
ip route flush proto 192
|
||||
ip route flush proto 193
|
||||
ip route flush proto 194
|
||||
else
|
||||
[ -n "$dmn" ] && eval "${dmn/-/_}=0"
|
||||
start_watchfrr
|
||||
fi
|
||||
;;
|
||||
|
||||
reload)
|
||||
# Just apply the commands that have changed, no restart necessary
|
||||
if [ ! -x "$RELOAD_SCRIPT" ]; then
|
||||
echo "frr-reload - reload not supported. Use restart or install frr-pythontools package"
|
||||
exit 1
|
||||
fi
|
||||
NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}"
|
||||
if [ ! -r $NEW_CONFIG_FILE ]; then
|
||||
echo "Unable to read configuration file $NEW_CONFIG_FILE. Only supporting integrated config"
|
||||
exit 1
|
||||
fi
|
||||
echo "Applying only incremental changes to running configuration from frr.conf"
|
||||
"$RELOAD_SCRIPT" --reload /etc/frr/frr.conf
|
||||
exit $?
|
||||
;;
|
||||
|
||||
status)
|
||||
check_status $dmn
|
||||
exit $?
|
||||
;;
|
||||
|
||||
restart|force-reload)
|
||||
$0 stop $dmn
|
||||
sleep 1
|
||||
$0 start $dmn
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/frr {start|stop|status|reload|restart|force-reload|<priority>} [daemon]"
|
||||
echo " E.g. '/etc/init.d/frr 5' would start all daemons with a prio 1-5."
|
||||
echo " reload applies only modifications from the running config to all daemons."
|
||||
echo " reload neither restarts starts any daemon nor starts any new ones."
|
||||
echo " Read /usr/share/doc/frr/README.Debian for details."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -1,24 +0,0 @@
|
||||
[Unit]
|
||||
Description=FRRouting (FRR)
|
||||
Wants=network.target
|
||||
After=network-pre.target systemd-sysctl.service
|
||||
Before=network.target
|
||||
OnFailure=heartbeat-failed@%n.service
|
||||
|
||||
[Service]
|
||||
Nice=-5
|
||||
Type=forking
|
||||
NotifyAccess=all
|
||||
StartLimitInterval=3m
|
||||
StartLimitBurst=3
|
||||
TimeoutSec=2m
|
||||
WatchdogSec=60s
|
||||
RestartSec=5
|
||||
Restart=on-abnormal
|
||||
LimitNOFILE=1024
|
||||
ExecStart=/usr/lib/frr/frr start
|
||||
ExecStop=/usr/lib/frr/frr stop
|
||||
ExecReload=/usr/lib/frr/frr reload
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -376,15 +376,13 @@ rm -vf %{buildroot}%{_libdir}/frr/libyang_plugins/*.la
|
||||
# install /etc sources
|
||||
%if "%{initsystem}" == "systemd"
|
||||
mkdir -p %{buildroot}%{_unitdir}
|
||||
install -m644 %{zeb_rh_src}/frr.service %{buildroot}%{_unitdir}/frr.service
|
||||
install %{zeb_rh_src}/frr.init %{buildroot}%{_sbindir}/frr
|
||||
install -m644 %{zeb_src}/tools/frr.service %{buildroot}%{_unitdir}/frr.service
|
||||
%else
|
||||
mkdir -p %{buildroot}%{_initddir}
|
||||
install %{zeb_rh_src}/frr.init %{buildroot}%{_sbindir}/frr
|
||||
ln -s %{_sbindir}/frr %{buildroot}%{_initddir}/frr
|
||||
ln -s %{_sbindir}/frrinit.sh %{buildroot}%{_initddir}/frr
|
||||
%endif
|
||||
|
||||
install %{zeb_rh_src}/daemons %{buildroot}%{_sysconfdir}/frr
|
||||
install %{zeb_src}/tools/etc/frr/daemons %{buildroot}%{_sysconfdir}/frr
|
||||
# add rpki module to daemon
|
||||
%if %{with_rpki}
|
||||
sed -i -e 's/^\(bgpd_options=\)\(.*\)\(".*\)/\1\2 -M rpki\3/' %{buildroot}%{_sysconfdir}/frr/daemons
|
||||
@ -474,7 +472,7 @@ zebra_spec_add_service fabricd 2618/tcp "Fabricd vty"
|
||||
|
||||
# Fix bad path in previous config files
|
||||
# Config files won't get replaced by default, so we do this ugly hack to fix it
|
||||
%__sed -i 's|/etc/init.d/|%{_sbindir}/|g' %{configdir}/daemons 2> /dev/null || true
|
||||
%__sed -i 's|watchfrr_options=|#watchfrr_options=|g' %{configdir}/daemons 2> /dev/null || true
|
||||
|
||||
# With systemd, watchfrr is mandatory. Fix config to make sure it's enabled if
|
||||
# we install or upgrade to a frr built with systemd
|
||||
@ -632,7 +630,6 @@ fi
|
||||
%else
|
||||
%{_initddir}/frr
|
||||
%endif
|
||||
%{_sbindir}/frr
|
||||
%config(noreplace) %{_sysconfdir}/pam.d/frr
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/frr
|
||||
%{_sbindir}/frr-reload
|
||||
|
Loading…
Reference in New Issue
Block a user