From 8d13effbe551c267b640a237afa4879b13a510b6 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 5 Sep 2024 18:54:06 +0000 Subject: [PATCH] confd: Accept a custom timeout when loading startup/failure This will enable us to align this timeout with the other front-ends in the system. --- src/confd/bin/load | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/confd/bin/load b/src/confd/bin/load index e33f97eb..57dbce2b 100755 --- a/src/confd/bin/load +++ b/src/confd/bin/load @@ -40,6 +40,22 @@ err() # shellcheck disable=SC1091 . /etc/confdrc +sysrepocfg=sysrepocfg +while getopts "t:" opt; do + case ${opt} in + t) + sysrepocfg="$sysrepocfg -t $OPTARG" + ;; + esac +done +shift $((OPTIND - 1)) + +if [ $# -lt 1 ]; then + err "No configuration file supplied" + exit 1 +fi + + config=$1 if [ -f "/mnt/aux/test-mode" ] && [ "$config" = "startup-config" ]; then @@ -69,10 +85,10 @@ if [ ! -f "$fn" ]; then case "$config" in startup-config) note "startup-config missing, initializing running datastore from factory-config" - sysrepocfg -C factory-default + $sysrepocfg -C factory-default rc=$? note "saving factory-config to $STARTUP_CFG ..." - sysrepocfg -f json -X"$STARTUP_CFG" + $sysrepocfg -f json -X"$STARTUP_CFG" perms "$STARTUP_CFG" exit $rc ;; @@ -84,7 +100,7 @@ if [ ! -f "$fn" ]; then fi note "Loading $config ..." -if ! sysrepocfg -v3 -I"$fn" -f json; then +if ! $sysrepocfg -v3 -I"$fn" -f json; then case "$config" in startup-config) err "Failed loading $fn, reverting to Fail Secure mode!" @@ -94,8 +110,8 @@ if ! sysrepocfg -v3 -I"$fn" -f json; then "infix-factory-default:factory-default": {} } EOF - # Default timeout is 2 seconds, allow time to clean up shm - if ! sysrepocfg -f json -t 10 -R /tmp/factory.json; then + + if ! $sysrepocfg -f json -R /tmp/factory.json; then rm -f /etc/sysrepo/data/*startup* rm -f /etc/sysrepo/data/*running* rm -f /dev/shm/sr_*