From: David Lamparter Date: Fri, 26 Oct 2018 17:33:20 +0000 (+0200) Subject: build: apply DFLT_NAME/profiles in init script X-Git-Tag: base_7.3~99^2~7 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=684959068c7a26d74c628182957447035e2179c2;p=matthieu%2Ffrr.git build: apply DFLT_NAME/profiles in init script 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 --- diff --git a/configure.ac b/configure.ac index 6147ebf0d8..124312b1e8 100755 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons index 79c52d30d1..8bec3c5bb6 100644 --- a/tools/etc/frr/daemons +++ b/tools/etc/frr/daemons @@ -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 diff --git a/tools/frr.in b/tools/frr.in index a21b06752b..d9816c2568 100755 --- a/tools/frr.in +++ b/tools/frr.in @@ -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' diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in index 3fc38d4bed..0dfdfd0efa 100644 --- a/tools/frrcommon.sh.in +++ b/tools/frrcommon.sh.in @@ -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 #