From 946f2e6be131ce16bed07e25c93213aff1a6cb9c Mon Sep 17 00:00:00 2001 From: Martin <58894405+mews-se@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:48:01 +0200 Subject: [PATCH] Report the configured listen address after install (#2243) The final message always echoed $PORT, which falls back to the default when -p is not passed. Existing service files are kept as they are, so a plain upgrade on a host with a custom port reported that the agent runs on 45876 regardless of the actual configuration. Read the address from the active service file instead. LISTEN is checked before PORT to match the agent's own precedence in GetAddress, and the value is read as text so host:port and unix socket paths are reported as configured. --- supplemental/scripts/install-agent.sh | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/supplemental/scripts/install-agent.sh b/supplemental/scripts/install-agent.sh index 8398d0eb..b7907b1c 100755 --- a/supplemental/scripts/install-agent.sh +++ b/supplemental/scripts/install-agent.sh @@ -97,6 +97,30 @@ ensure_trailing_slash() { fi } +# Read the listen address from the active service configuration. Existing +# service files are kept as they are, so the configured address can differ from +# $PORT, which falls back to the default when -p is not passed. LISTEN is +# checked before PORT to match the agent's own precedence, and the value is read +# as text so host:port and unix socket paths survive. +configured_address() { + if is_alpine || is_openwrt; then + address_file=/etc/init.d/beszel-agent + elif is_freebsd; then + address_file="$AGENT_DIR/env" + else + address_file=/etc/systemd/system/beszel-agent.service + fi + + [ -f "$address_file" ] || return 0 + + address_value=$(sed -n 's/.*LISTEN="\{0,1\}\([^"]*\)"\{0,1\}.*/\1/p' "$address_file" | head -n 1) + if [ -z "$address_value" ]; then + address_value=$(sed -n 's/.*PORT="\{0,1\}\([^"]*\)"\{0,1\}.*/\1/p' "$address_file" | head -n 1) + fi + + printf '%s\n' "$address_value" +} + # Escape text for use in the replacement portion of a sed s command whose # delimiter is |. This only escapes sed replacement metacharacters; quoting # for the destination configuration syntax is handled separately. @@ -1198,4 +1222,7 @@ EOF fi fi -printf "\n\033[32mBeszel Agent has been installed successfully! It is now running on $PORT.\033[0m\n" +RUNNING_ADDRESS=$(configured_address) +[ -n "$RUNNING_ADDRESS" ] || RUNNING_ADDRESS=$PORT + +printf "\n\033[32mBeszel Agent has been installed successfully! It is now running on $RUNNING_ADDRESS.\033[0m\n"