fix(agent-arka): do not trip set -u in the installer EXIT trap
This commit is contained in:
1 parent
5170fab5e8
commit
23c2841119
1 file changed
+14
-12
+14
-12
@@ -33,6 +33,10 @@ ok() { printf '%s✓%s %s\n' "$C_GREEN" "$C_RESET" "$*"; }
|
|||||||
warn() { printf '%s⚠%s %s\n' "$C_YELLOW" "$C_RESET" "$*"; }
|
warn() { printf '%s⚠%s %s\n' "$C_YELLOW" "$C_RESET" "$*"; }
|
||||||
die() { printf '%s✗%s %s\n' "$C_RED" "$C_RESET" "$*" >&2; exit 1; }
|
die() { printf '%s✗%s %s\n' "$C_RED" "$C_RESET" "$*" >&2; exit 1; }
|
||||||
|
|
||||||
|
_aa_tmp=""
|
||||||
|
cleanup() { [[ -n "${_aa_tmp:-}" ]] && rm -rf "$_aa_tmp"; }
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
brand_env() {
|
brand_env() {
|
||||||
local suffix="$1"
|
local suffix="$1"
|
||||||
local new_name="AGENT_ARKA_${suffix}"
|
local new_name="AGENT_ARKA_${suffix}"
|
||||||
@@ -175,27 +179,25 @@ main() {
|
|||||||
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
||||||
local url="${PUBLIC_DL}/${tag}/${asset}"
|
local url="${PUBLIC_DL}/${tag}/${asset}"
|
||||||
local sums_url="${PUBLIC_DL}/${tag}/SHA256SUMS"
|
local sums_url="${PUBLIC_DL}/${tag}/SHA256SUMS"
|
||||||
local tmp
|
_aa_tmp=$(mktemp -d)
|
||||||
tmp=$(mktemp -d)
|
|
||||||
trap 'rm -rf "$tmp"' EXIT
|
|
||||||
|
|
||||||
info "Downloading ${asset}"
|
info "Downloading ${asset}"
|
||||||
if ! curl -fL --retry 3 -o "${tmp}/${asset}" "$url"; then
|
if ! curl -fsSL --retry 3 -o "${_aa_tmp}/${asset}" "$url"; then
|
||||||
die "No package for ${PLATFORM} in ${tag}. See https://git.arka-ai.ru/arka/public/releases"
|
die "No package for ${PLATFORM} in ${tag}. See https://git.arka-ai.ru/arka/public/releases"
|
||||||
fi
|
fi
|
||||||
curl -fsSL -o "${tmp}/SHA256SUMS" "$sums_url" || die "Missing SHA256SUMS for ${tag}"
|
curl -fsSL -o "${_aa_tmp}/SHA256SUMS" "$sums_url" || die "Missing SHA256SUMS for ${tag}"
|
||||||
local expected actual
|
local expected actual
|
||||||
expected=$(grep -E "[[:space:]]${asset}\$" "${tmp}/SHA256SUMS" | awk '{print $1}' | head -n 1)
|
expected=$(grep -E "[[:space:]]${asset}\$" "${_aa_tmp}/SHA256SUMS" | awk '{print $1}' | head -n 1)
|
||||||
[[ -n "$expected" ]] || die "SHA256SUMS has no entry for ${asset}"
|
[[ -n "$expected" ]] || die "SHA256SUMS has no entry for ${asset}"
|
||||||
actual=$(sha256_file "${tmp}/${asset}")
|
actual=$(sha256_file "${_aa_tmp}/${asset}")
|
||||||
[[ "$expected" == "$actual" ]] || die "SHA256 mismatch for ${asset} (got ${actual}, want ${expected})"
|
[[ "$expected" == "$actual" ]] || die "SHA256 mismatch for ${asset} (got ${actual}, want ${expected})"
|
||||||
ok "Checksum ok"
|
ok "Checksum ok"
|
||||||
|
|
||||||
tar -xzf "${tmp}/${asset}" -C "$tmp"
|
tar -xzf "${_aa_tmp}/${asset}" -C "$_aa_tmp"
|
||||||
[[ -f "${tmp}/agent-arka" ]] || die "Archive did not contain agent-arka"
|
[[ -f "${_aa_tmp}/agent-arka" ]] || die "Archive did not contain agent-arka"
|
||||||
chmod 755 "${tmp}/agent-arka"
|
chmod 755 "${_aa_tmp}/agent-arka"
|
||||||
"${tmp}/agent-arka" --version >/dev/null || die "Downloaded binary failed to run on this host"
|
"${_aa_tmp}/agent-arka" --version >/dev/null || die "Downloaded binary failed to run on this host"
|
||||||
cp -f "${tmp}/agent-arka" "${bindir}/agent-arka"
|
cp -f "${_aa_tmp}/agent-arka" "${bindir}/agent-arka"
|
||||||
ln -sfn agent-arka "${bindir}/librefang"
|
ln -sfn agent-arka "${bindir}/librefang"
|
||||||
ok "Installed ${bindir}/agent-arka ($("${bindir}/agent-arka" --version 2>/dev/null | head -n 1))"
|
ok "Installed ${bindir}/agent-arka ($("${bindir}/agent-arka" --version 2>/dev/null | head -n 1))"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user