From: Martin Winter Date: Sat, 15 Apr 2017 10:13:07 +0000 (-0700) Subject: redhat: Add (combined) init.d script for FRR with daemon selection based on /etc... X-Git-Tag: reindent-master-before~92^2~2^2~12 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c2953ac5d66c071c38e80305ba9d62d44da40625;p=matthieu%2Ffrr.git redhat: Add (combined) init.d script for FRR with daemon selection based on /etc/frr/daemons - Provide new frr init script - Remove separate per-deamon init.d scripts Signed-off-by: Martin Winter --- diff --git a/redhat/Makefile.am b/redhat/Makefile.am index f7a143ff73..0a851a38d2 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -1,8 +1,5 @@ -EXTRA_DIST = bgpd.init isisd.init \ - ospf6d.init ospfd.init ldpd.init \ +EXTRA_DIST = frr.init daemons \ frr.logrotate frr.pam frr.spec \ - frr.sysconfig ripd.init ripngd.init \ - watchfrr.init pimd.init zebra.init \ README.rpm_build.md diff --git a/redhat/bgpd.init b/redhat/bgpd.init deleted file mode 100644 index d200b0baaa..0000000000 --- a/redhat/bgpd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/bgpd.conf - -### BEGIN INIT INFO -# Provides: bgpd -# Short-Description: BGP routing engine -# Description: BGP routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="bgpd" -cmd=bgpd -LOCK_FILE=/var/lock/subsys/bgpd -CONF_FILE=/etc/frr/bgpd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $BGPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/daemons b/redhat/daemons new file mode 100644 index 0000000000..ce0f7747a2 --- /dev/null +++ b/redhat/daemons @@ -0,0 +1,59 @@ +# This file tells the frr package which daemons to start. +# +# Entries are in the format: =(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 . +# 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 > +# +# 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=no +watchfrr_options=("-Az" "-b_" "-r/etc/init.d/frr_restart_%s" "-s/etc/init.d/frr_start_%s" "-k/etc/init.d/frr_stop_%s") +# +zebra=no +bgpd=no +ospfd=no +ospf6d=no +ripd=no +ripngd=no +isisd=no +ldpd=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") + diff --git a/redhat/frr.init b/redhat/frr.init new file mode 100755 index 0000000000..c8c0cee407 --- /dev/null +++ b/redhat/frr.init @@ -0,0 +1,555 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/frr +# +# Start/Stop the FRR Routing daemons +# +# +# 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 ldpd" +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() +{ + ulimit -n $MAX_FDS > /dev/null 2> /dev/null + if [ "$1" = "watchfrr" ]; then + + # We may need to restart watchfrr if new daemons are added and/or + # removed + if started "$1" ; then + stop watchfrr + else + # Echo only once. watchfrr is printed in the stop above + echo -n " $1" + fi + + if [ -e /var/run/frr/watchfrr.started ] ; then + rm /var/run/frr/watchfrr.started + fi + daemon --pidfile=`pidfile $1` "$D_PATH/$1" -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 "$2" ]; then + echo -n " $1-$2" + if ! check_daemon $1 $2 ; then + echo -n " (binary does not exist)" + return; + fi + daemon --pidfile=`pidfile $1-$2` "$D_PATH/$1" -d `eval echo "$""$1""_options"` -n "$2" + RETVAL=$? + else + echo -n " $1 " + if ! check_daemon $1; then + echo " (binary does not exist)" + return; + fi + daemon --pidfile=`pidfile $1` "$D_PATH/$1" -d `eval echo "$""$1""_options"` + RETVAL=$? + fi + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$1 + 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 + echo + echo "ERROR: The variable watchfrr_options from /etc/frr/daemons must be a BASH array!" + echo "ERROR: Please convert config file and restart!" + exit 1 + 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+=("${daemon_name}-${inst}") + fi + fi + done + else + if check_daemon $daemon_name; then + 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 + else + [ -n "$dmn" ] && eval "${dmn/-/_}=0" + start_watchfrr + fi + ;; + + reload) + # Just apply the commands that have changed, no restart necessary + [ ! -x "$RELOAD_SCRIPT" ] && echo "frr-reload script not available" && exit 0 + NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}" + [ ! -r $NEW_CONFIG_FILE ] && echo "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1 + 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|} [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 diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 354a73242d..17a07d1555 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -34,7 +34,6 @@ %define zeb_rh_src %{zeb_src}/redhat %define zeb_docs %{zeb_src}/doc %define frr_tools %{zeb_src}/tools -%define cumulus_dir %{zeb_src}/cumulus/etc # defines for configure %define _localstatedir /var/run/frr @@ -162,8 +161,8 @@ Contributed/3rd party tools which may be of use with frr. %package pythontools Summary: python tools for frr -BuildRequires: python >= 2.7 -Requires: python >= 2.7 python-ipaddr +BuildRequires: python +Requires: python python-ipaddr Group: System Environment/Daemons %description pythontools @@ -303,17 +302,11 @@ install %{frr_tools}/frr.service \ %{buildroot}%{_unitdir}/frr.service %else mkdir -p %{buildroot}/etc/rc.d/init.d -for daemon in %{all_daemons} ; do - if [ x"${daemon}" != x"" ] ; then - install %{zeb_rh_src}/${daemon}.init \ - %{buildroot}/etc/rc.d/init.d/${daemon} - fi -done +install %{zeb_rh_src}/frr.init \ + %{buildroot}/etc/rc.d/init.d/frr %endif -install %{cumulus_dir}/frr/debian.conf %{buildroot}/etc/frr -install %{cumulus_dir}/frr/daemons %{buildroot}/etc/frr -install -m644 %{cumulus_dir}/default/frr %{buildroot}/etc/default +install %{zeb_rh_src}/daemons %{buildroot}/etc/frr install -m644 %{zeb_rh_src}/frr.pam \ %{buildroot}/etc/pam.d/frr install -m644 %{zeb_rh_src}/frr.logrotate \ @@ -380,11 +373,7 @@ for daemon in %all_daemons ; do %systemd_post frr.service done %else -for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - /sbin/chkconfig --add ${daemon} - fi -done +/sbin/chkconfig --add frr %endif /sbin/install-info %{_infodir}/frr.info.gz %{_infodir}/dir @@ -521,12 +510,8 @@ fi ## init.d Version ## if [ "$1" = "0" ]; then - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - /sbin/chkconfig --del ${daemon} - fi - done + /etc/rc.d/init.d/frr stop >/dev/null 2>&1 + /sbin/chkconfig --del frr fi %endif /sbin/install-info --delete %{_infodir}/frr.info.gz %{_infodir}/dir @@ -572,7 +557,7 @@ rm -rf %{buildroot} %endif %{_sbindir}/isisd %if %{with_ldpd} -%{_sbindir}/ldpd + %{_sbindir}/ldpd %endif %if %{with_shared} %{_libdir}/lib*.so @@ -584,24 +569,9 @@ rm -rf %{buildroot} %if "%{initsystem}" == "systemd" %config %{_unitdir}/frr.service %else - %config /etc/rc.d/init.d/zebra - %if %{with_watchfrr} - %config /etc/rc.d/init.d/watchfrr - %endif - %config /etc/rc.d/init.d/ripd - %config /etc/rc.d/init.d/ospfd - %config /etc/rc.d/init.d/bgpd - %config /etc/rc.d/init.d/ripngd - %config /etc/rc.d/init.d/ospf6d - %config /etc/rc.d/init.d/isisd - %if %{with_pimd} - %config /etc/rc.d/init.d/pimd - %endif - %if %{with_ldpd} - %config /etc/rc.d/init.d/ldpd - %endif + %config /etc/rc.d/init.d/frr %endif -%config(noreplace) /etc/default/frr +%config /etc/frr/daemons %config(noreplace) /etc/pam.d/frr %config(noreplace) %attr(640,root,root) /etc/logrotate.d/* diff --git a/redhat/frr.sysconfig b/redhat/frr.sysconfig deleted file mode 100644 index 97c28c807d..0000000000 --- a/redhat/frr.sysconfig +++ /dev/null @@ -1,25 +0,0 @@ -# -# Default: Bind all daemon vtys to the loopback(s) only -# -BGPD_OPTS="-A 127.0.0.1" -ISISD_OPTS="-A ::1" -OSPF6D_OPTS="-A ::1" -OSPFD_OPTS="-A 127.0.0.1" -RIPD_OPTS="-A 127.0.0.1" -RIPNGD_OPTS="-A ::1" -ZEBRA_OPTS="-A 127.0.0.1" -PIMD_OPTS="-A 127.0.0.1" -LDPD_OPTS="-A 127.0.0.1" - -# Watchfrr configuration for LSB initscripts -# -# (Not needed with systemd: the service files are configured to automatically -# restart any daemon on failure. If zebra fails, all running daemons will be -# stopped; zebra will be started again; and then the previously running daemons -# will be started again.) -# -# Uncomment and edit this line to reflect the daemons you are actually using: -#WATCH_DAEMONS="zebra bgpd ospfd ospf6d ripd ripngd" -# -# Timer values can be adjusting by editing this line: -WATCH_OPTS="-Az -b_ -r/sbin/service_%s_restart -s/sbin/service_%s_start -k/sbin/service_%s_stop" diff --git a/redhat/isisd.init b/redhat/isisd.init deleted file mode 100644 index b309e07542..0000000000 --- a/redhat/isisd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/isisd.conf - -### BEGIN INIT INFO -# Provides: isisd -# Short-Description: IS-IS routing engine -# Description: IS-IS routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="isisd" -cmd=isisd -LOCK_FILE=/var/lock/subsys/isisd -CONF_FILE=/etc/frr/isisd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $ISISD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ldpd.init b/redhat/ldpd.init deleted file mode 100644 index 3ade9bfe9f..0000000000 --- a/redhat/ldpd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ldpd.conf - -### BEGIN INIT INFO -# Provides: ldpd -# Short-Description: LDP engine -# Description: LDP engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ldpd" -cmd=ldpd -LOCK_FILE=/var/lock/subsys/ldpd -CONF_FILE=/etc/frr/ldpd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $LDPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ospf6d.init b/redhat/ospf6d.init deleted file mode 100644 index 5c5a2af236..0000000000 --- a/redhat/ospf6d.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ospf6d.conf - -### BEGIN INIT INFO -# Provides: ospf6d -# Short-Description: OSPF routing engine for IPv6 -# Description: OSPF routing engine for use with Zebra and IPv6 -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ospf6d" -cmd=ospf6d -LOCK_FILE=/var/lock/subsys/ospf6d -CONF_FILE=/etc/frr/ospf6d.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $OSPF6D_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ospfd.init b/redhat/ospfd.init deleted file mode 100644 index e9cbbc739c..0000000000 --- a/redhat/ospfd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ospfd.conf - -### BEGIN INIT INFO -# Provides: ospfd -# Short-Description: OSPF routing engine -# Description: OSPF routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ospfd" -cmd=ospfd -LOCK_FILE=/var/lock/subsys/ospfd -CONF_FILE=/etc/frr/ospfd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $OSPFD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/pimd.init b/redhat/pimd.init deleted file mode 100644 index 85cbf8d2b1..0000000000 --- a/redhat/pimd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/pimd.conf - -### BEGIN INIT INFO -# Provides: pimd -# Short-Description: PIM multicast routing engine -# Description: PIM routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="pimd" -cmd=pimd -LOCK_FILE=/var/lock/subsys/pimd -CONF_FILE=/etc/frr/pimd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $PIMD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ripd.init b/redhat/ripd.init deleted file mode 100644 index 8e25a83f4b..0000000000 --- a/redhat/ripd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ripd.conf - -### BEGIN INIT INFO -# Provides: ripd -# Short-Description: RIP routing engine -# Description: RIP routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ripd" -cmd=ripd -LOCK_FILE=/var/lock/subsys/ripd -CONF_FILE=/etc/frr/ripd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $RIPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ripngd.init b/redhat/ripngd.init deleted file mode 100644 index 7b9fde4085..0000000000 --- a/redhat/ripngd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ripngd.conf - -### BEGIN INIT INFO -# Provides: ripngd -# Short-Description: RIP routing engine for IPv6 -# Description: RIP routing engine for use with Zebra and IPv6 -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ripngd" -cmd=ripngd -LOCK_FILE=/var/lock/subsys/ripngd -CONF_FILE=/etc/frr/ripngd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $RIPNGD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/watchfrr.init b/redhat/watchfrr.init deleted file mode 100644 index bc83415167..0000000000 --- a/redhat/watchfrr.init +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# chkconfig: 2345 17 83 - -### BEGIN INIT INFO -# Provides: watchfrr -# Short-Description: Frr watchdog -# Description: Frr watchdog for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="watchfrr" -cmd=watchfrr -LOCK_FILE=/var/lock/subsys/watchfrr - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # Check that there are daemons to be monitored. - [ -z "$WATCH_DAEMONS" ] && exit 1 - - echo -n $"Starting $PROG: " - daemon $cmd -d $WATCH_OPTS $WATCH_DAEMONS - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/zebra.init b/redhat/zebra.init deleted file mode 100644 index 1afb785431..0000000000 --- a/redhat/zebra.init +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# chkconfig: - 15 85 -# config: /etc/frr/zebra.conf - -### BEGIN INIT INFO -# Provides: zebra -# Short-Description: GNU Zebra routing manager -# Description: GNU Zebra routing manager -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="zebra" -cmd=zebra -LOCK_FILE=/var/lock/subsys/zebra -CONF_FILE=/etc/frr/zebra.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - /sbin/ip route flush proto zebra - daemon $cmd -d $ZEBRA_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL