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" "$*"; }
|
||||
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() {
|
||||
local suffix="$1"
|
||||
local new_name="AGENT_ARKA_${suffix}"
|
||||
@@ -175,27 +179,25 @@ main() {
|
||||
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
||||
local url="${PUBLIC_DL}/${tag}/${asset}"
|
||||
local sums_url="${PUBLIC_DL}/${tag}/SHA256SUMS"
|
||||
local tmp
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
_aa_tmp=$(mktemp -d)
|
||||
|
||||
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"
|
||||
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
|
||||
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}"
|
||||
actual=$(sha256_file "${tmp}/${asset}")
|
||||
actual=$(sha256_file "${_aa_tmp}/${asset}")
|
||||
[[ "$expected" == "$actual" ]] || die "SHA256 mismatch for ${asset} (got ${actual}, want ${expected})"
|
||||
ok "Checksum ok"
|
||||
|
||||
tar -xzf "${tmp}/${asset}" -C "$tmp"
|
||||
[[ -f "${tmp}/agent-arka" ]] || die "Archive did not contain agent-arka"
|
||||
chmod 755 "${tmp}/agent-arka"
|
||||
"${tmp}/agent-arka" --version >/dev/null || die "Downloaded binary failed to run on this host"
|
||||
cp -f "${tmp}/agent-arka" "${bindir}/agent-arka"
|
||||
tar -xzf "${_aa_tmp}/${asset}" -C "$_aa_tmp"
|
||||
[[ -f "${_aa_tmp}/agent-arka" ]] || die "Archive did not contain agent-arka"
|
||||
chmod 755 "${_aa_tmp}/agent-arka"
|
||||
"${_aa_tmp}/agent-arka" --version >/dev/null || die "Downloaded binary failed to run on this host"
|
||||
cp -f "${_aa_tmp}/agent-arka" "${bindir}/agent-arka"
|
||||
ln -sfn agent-arka "${bindir}/librefang"
|
||||
ok "Installed ${bindir}/agent-arka ($("${bindir}/agent-arka" --version 2>/dev/null | head -n 1))"
|
||||
|
||||
|
||||
Reference in new issue
Block a user