summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2018-10-26 19:33:20 +0200
committerDavid Lamparter <equinox@diac24.net>2019-12-06 15:13:32 +0100
commit684959068c7a26d74c628182957447035e2179c2 (patch)
treec91097c18d41262acdf7acaea104d596043784f1 /tools
parentlib/defaults: add bool variable support (diff)
downloadfrr-684959068c7a26d74c628182957447035e2179c2.tar.xz
frr-684959068c7a26d74c628182957447035e2179c2.zip
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 <equinox@diac24.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/etc/frr/daemons5
-rwxr-xr-xtools/frr.in21
-rw-r--r--tools/frrcommon.sh.in15
3 files changed, 36 insertions, 5 deletions
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
index 79c52d30d..8bec3c5bb 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 a21b06752..d9816c256 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 3fc38d4be..0dfdfd0ef 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
#