feat: installer fetched from the direct address sets it as the agent's own with the main one as fallback (and downloads from it); agents fall back to whichever address is not theirs; (direct) beside the connection status
This commit is contained in:
1 parent
021da93229
commit
79828e3f8a
11 files changed
+72
-25
No files matched your search
@@ -7,9 +7,10 @@
|
||||
set -eu
|
||||
|
||||
HOST="${HOST:-{{.Host}}}"
|
||||
# The direct address (not behind a proxy like Cloudflare): the agent turns to
|
||||
# it when the main one is out of reach.
|
||||
FALLBACK_HOST="${FALLBACK_HOST:-{{.Direct}}}"
|
||||
# The server's other address (the direct one, not behind a proxy like
|
||||
# Cloudflare, or the main one when this script came from the direct one): the
|
||||
# agent turns to it when HOST is out of reach.
|
||||
FALLBACK_HOST="${FALLBACK_HOST:-{{.Fallback}}}"
|
||||
{{if .Secret}}ENROLL_SECRET="${ENROLL_SECRET:-{{.Secret}}}"
|
||||
{{end}}
|
||||
BIN_PATH="/usr/local/bin/lpagent"
|
||||
@@ -123,7 +124,7 @@ bold "Скачивание агента ($ARCH) с $HOST…"
|
||||
TMP="$(mktemp)"
|
||||
if ! download "$HOST/download/agent-linux-$ARCH" "$TMP"; then
|
||||
if [ -n "$FALLBACK_HOST" ] && [ "$FALLBACK_HOST" != "$HOST" ]; then
|
||||
bold "Основной адрес недоступен, скачивание с $FALLBACK_HOST…"
|
||||
bold "$HOST недоступен, скачивание с $FALLBACK_HOST…"
|
||||
download "$FALLBACK_HOST/download/agent-linux-$ARCH" "$TMP"
|
||||
else
|
||||
red "Не удалось скачать агента."; exit 1
|
||||
|
||||
Reference in new issue
Block a user