]> git.puffer.fish Git - matthieu/frr.git/commitdiff
build: apply DFLT_NAME/profiles in init script
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 26 Oct 2018 17:33:20 +0000 (19:33 +0200)
committerDavid Lamparter <equinox@diac24.net>
Fri, 6 Dec 2019 14:13:32 +0000 (15:13 +0100)
Hopefully at some point we can get rid of the --enable-datacenter switch
and just have the init script do magic.  Should already work for Cumulus
as it is.

NB: the profile name can't be baked into the package.  The whole point
is to make the package profile-agnostic;  in theory at some point the
exact same package files should work on both, say, a Cumulus switch and
a Linux software BGP DFZ router.

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac
tools/etc/frr/daemons
tools/frr.in
tools/frrcommon.sh.in

index 6147ebf0d8db79d4609572f40f5925c2047a31e4..124312b1e8c448bd590fc5443eeee19e588682a8 100755 (executable)
@@ -643,6 +643,7 @@ fi
 
 if test "${enable_datacenter}" = "yes" ; then
   AC_DEFINE([HAVE_DATACENTER], [1], [Compile extensions for a DataCenter])
+  AC_MSG_WARN([The --enable-datacenter compile time option is deprecated.  Please modify the init script to pass -F datacenter to the daemons instead.])
   DFLT_NAME="datacenter"
 else
   DFLT_NAME="traditional"
index 79c52d30d103de5fd332f1505997432ec85db793..8bec3c5bb68d6a3da38ff300a6a9e4b20319ba61 100644 (file)
@@ -56,6 +56,11 @@ bfdd_options="   -A 127.0.0.1"
 fabricd_options="-A 127.0.0.1"
 vrrpd_options="  -A 127.0.0.1"
 
+# configuration profile
+#
+#frr_profile="traditional"
+#frr_profile="datacenter"
+
 #
 # This is the maximum number of FD's that will be available.
 # Upon startup this is read by the control files and ulimit
index a21b06752b0f62e654656673f029d9286a381d97..d9816c2568197ef9035d133851e32db5ae46aafa 100755 (executable)
@@ -21,6 +21,7 @@ VTYSH="@vtysh_bin@" # /usr/bin/vtysh
 FRR_USER="@enable_user@" # frr
 FRR_GROUP="@enable_group@" # frr
 FRR_VTY_GROUP="@enable_vty_group@" # frrvty
+FRR_DEFAULT_PROFILE="@DFLT_NAME@" # traditional / datacenter
 
 # Local Daemon selection may be done by using /etc/frr/daemons.
 # See /usr/share/doc/frr/README.Debian.gz for further information.
@@ -151,7 +152,7 @@ start()
                        --pidfile=`pidfile $dmn-$inst` \
                        --exec "$D_PATH/$dmn" \
                        -- \
-                       `eval echo "$""$dmn""_options"` -n "$inst"
+                       `eval echo "$""$dmn""_options"` $frr_global_options -n "$inst"
        else
                if ! check_daemon $dmn; then
                        echo -n " (binary does not exist)"
@@ -164,14 +165,14 @@ start()
                                --pidfile=`pidfile $dmn` \
                                --exec "$valgrind" \
                                -- --trace-children=no --leak-check=full --log-file=/var/log/frr/$dmn-valgrind.log $D_PATH/$dmn \
-                               `eval echo "$""$dmn""_options"`
+                               `eval echo "$""$dmn""_options"` $frr_global_options
                else
                        ${SSD} \
                                --start \
                                --pidfile=`pidfile $dmn` \
                                --exec "$D_PATH/$dmn" \
                                -- \
-                               `eval echo "$""$dmn""_options"`
+                               `eval echo "$""$dmn""_options"` $frr_global_options
                fi
        fi
 
@@ -188,7 +189,7 @@ start()
                        --pidfile=`pidfile staticd` \
                        --exec "$D_PATH/staticd" \
                        -- \
-                       `eval echo "$"staticd"_options"`
+                       `eval echo "$"staticd"_options"` $frr_global_options
        fi
 }
 
@@ -511,6 +512,18 @@ fi
 # Read configuration variable file if it is present
 [ -r /etc/default/frr ] && . /etc/default/frr
 
+if test -z "$frr_profile"; then
+       # try to autodetect config profile
+       if test -d /etc/cumulus; then
+               frr_profile=datacenter
+       # elif test ...; then
+       # -- add your distro/system here
+       elif test -n "$FRR_DEFAULT_PROFILE"; then
+               frr_profile="$FRR_DEFAULT_PROFILE"
+       fi
+fi
+test -n "$frr_profile" && frr_global_options="$frr_global_options -F $frr_profile"
+
 MAX_INSTANCES=${MAX_INSTANCES:=5}
 
 # Set priority of un-startable daemons to 'no' and substitute 'yes' to '0'
index 3fc38d4bed807bedd3149d7f2beafbf42cee14f3..0dfdfd0efabeebaacc019ae896aca38ed62481f6 100644 (file)
@@ -24,6 +24,7 @@ VTYSH="@vtysh_bin@" # /usr/bin/vtysh
 FRR_USER="@enable_user@" # frr
 FRR_GROUP="@enable_group@" # frr
 FRR_VTY_GROUP="@enable_vty_group@" # frrvty
+FRR_DEFAULT_PROFILE="@DFLT_NAME@" # traditional / datacenter
 
 # ORDER MATTERS FOR $DAEMONS!
 # - keep zebra first
@@ -151,7 +152,7 @@ daemon_start() {
        instopt="${inst:+-n $inst}"
        eval args="\$${daemon}_options"
 
-       if eval "$all_wrap $wrap $bin -d $instopt $args"; then
+       if eval "$all_wrap $wrap $bin -d $frr_global_options $instopt $args"; then
                log_success_msg "Started $dmninst"
                vtysh_b "$daemon"
        else
@@ -298,6 +299,18 @@ if { declare -p watchfrr_options 2>/dev/null || true; } | grep -q '^declare \-a'
        unset watchfrr_options
 fi
 
+if test -z "$frr_profile"; then
+       # try to autodetect config profile
+       if test -d /etc/cumulus; then
+               frr_profile=datacenter
+       # elif test ...; then
+       # -- add your distro/system here
+       elif test -n "$FRR_DEFAULT_PROFILE"; then
+               frr_profile="$FRR_DEFAULT_PROFILE"
+       fi
+fi
+test -n "$frr_profile" && frr_global_options="$frr_global_options -F $frr_profile"
+
 #
 # other defaults and dispatch
 #