From ae773456f6964e3a1eedff29e7cde3c3eb34ce5c Mon Sep 17 00:00:00 2001 From: Adel Kara Slimane Date: Tue, 14 Nov 2023 09:40:22 +0100 Subject: [PATCH] install.sh: fix handling of env var config overrides (#845) overriding config values through environment variables wasn't working because the script call was resetting them before they were saved also, the external config file was getting sourced twice --- install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 65b9544..c32bfba 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Stop the script at any ecountered error +set -e + +# save current environment before losing it to the script call +declare -p -x > current_env + # If current run is not using 'script' for logging, do it if [ -z "$SCRIPT" ]; then export SCRIPT=1 @@ -11,8 +17,7 @@ if [ -z "$SCRIPT" ]; then exit $exit_status fi -# Stop the script at any ecountered error -set -e +###################### Definition of helper variables and functions _where=`pwd` srcdir="$_where" @@ -42,7 +47,10 @@ plain() { echo -e "$1" >&2 } -declare -p -x > current_env +#################################################################### + +################### Config sourcing + source customization.cfg if [ -e "$_EXT_CONFIG_PATH" ]; then @@ -54,6 +62,8 @@ fi source linux-tkg-config/prepare +#################################################################### + _distro_prompt() { echo "Which linux distribution are you running ?" echo "if it's not on the list, chose the closest one to it: Fedora/Suse for RPM, Ubuntu/Debian for DEB" @@ -89,12 +99,6 @@ if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ] exit 0 fi -# Load external configuration file if present. Available variable values will overwrite customization.cfg ones. -if [ -e "$_EXT_CONFIG_PATH" ]; then - msg2 "External configuration file $_EXT_CONFIG_PATH will be used and will override customization.cfg values." - source "$_EXT_CONFIG_PATH" -fi - if [ "$1" = "install" ] || [ "$1" = "config" ]; then if [ -z "$_distro" ] && [ "$1" = "install" ]; then