From 23bf6bb9e0eb34ce61272e06df24283febdcf92f Mon Sep 17 00:00:00 2001 From: Alex Hope-O'Connor Date: Thu, 5 Feb 2026 04:04:56 +1000 Subject: [PATCH] install.sh: fix collect_config under set -e when no config - Use set +e around env/grep/read so grep (no match), read (EOF), and [ -f ]/[ -s ] do not exit the script when no DNSMASQ_WEBUI_* or --set - Write env vars to temp file .env then read; only process when file exists and is non-empty - Add || true after [ -s CONFIG_SET_FILE ] && cat so empty CONFIG_SET_FILE does not trigger exit Fixes install/update with no config (e.g. plain --version/--update --dir) failing silently under sh (dash). --- scripts/install.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 41a67fb..7bc8ad6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -100,15 +100,21 @@ trim_repo() { collect_config() { CONFIG_VARS_FILE="$(mktemp)" export CONFIG_VARS_FILE - # Env vars: strip DNSMASQ_WEBUI_ prefix; key=value per line - env | grep '^DNSMASQ_WEBUI_' | while IFS= read -r line; do - key="${line%%=*}" - key="${key#DNSMASQ_WEBUI_}" - value="${line#*=}" - printf '%s=%s\n' "$key" "$value" >> "$CONFIG_VARS_FILE" - done + # Env vars: strip DNSMASQ_WEBUI_ prefix; key=value per line. set +e so grep (no match) / read (EOF) / [ -f ] do not trigger exit. + set +e + env | grep '^DNSMASQ_WEBUI_' > "${CONFIG_VARS_FILE}.env" 2>/dev/null + if [ -f "${CONFIG_VARS_FILE}.env" ] && [ -s "${CONFIG_VARS_FILE}.env" ]; then + while IFS= read -r line; do + key="${line%%=*}" + key="${key#DNSMASQ_WEBUI_}" + value="${line#*=}" + printf '%s=%s\n' "$key" "$value" >> "$CONFIG_VARS_FILE" + done < "${CONFIG_VARS_FILE}.env" + fi + rm -f "${CONFIG_VARS_FILE}.env" + set -e # --set lines (last occurrence of each key wins when systemd reads the file) - [ -s "$CONFIG_SET_FILE" ] && cat "$CONFIG_SET_FILE" >> "$CONFIG_VARS_FILE" + [ -s "$CONFIG_SET_FILE" ] && cat "$CONFIG_SET_FILE" >> "$CONFIG_VARS_FILE" || true } # Write env file for the app/service. $1 = path. Adds ASPNETCORE_URLS=http://0.0.0.0:8080 if not in config (for service).