From 24fd7e2755bed3a854f8089c2db2fed89eb07f56 Mon Sep 17 00:00:00 2001 From: ramboman Date: Sat, 24 Feb 2024 01:00:13 +0000 Subject: [PATCH] `install-multi-user.sh`: `_sudo`: add proxy variables to sudo --- scripts/install-multi-user.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/install-multi-user.sh b/scripts/install-multi-user.sh index ad3ee8881..1dbb93bf9 100644 --- a/scripts/install-multi-user.sh +++ b/scripts/install-multi-user.sh @@ -58,6 +58,31 @@ readonly EXTRACTED_NIX_PATH="$(dirname "$0")" readonly ROOT_HOME=~root +readonly PROXY_ENVIRONMENT_VARIABLES=( + http_proxy + https_proxy + ftp_proxy + no_proxy + HTTP_PROXY + HTTPS_PROXY + FTP_PROXY + NO_PROXY +) + +SUDO_EXTRA_ENVIRONMENT_VARIABLES=() + +setup_sudo_extra_environment_variables() { + local i=${#SUDO_EXTRA_ENVIRONMENT_VARIABLES[@]} + for variable in "${PROXY_ENVIRONMENT_VARIABLES[@]}"; do + if [ "x${!variable:-}" != "x" ]; then + SUDO_EXTRA_ENVIRONMENT_VARIABLES[i]="$variable=${!variable}" + i=$((i + 1)) + fi + done +} + +setup_sudo_extra_environment_variables + if [ -t 0 ] && [ -z "${NIX_INSTALLER_YES:-}" ]; then readonly IS_HEADLESS='no' else @@ -361,7 +386,7 @@ _sudo() { if is_root; then env "$@" else - sudo "$@" + sudo "${SUDO_EXTRA_ENVIRONMENT_VARIABLES[@]}" "$@" fi }