|
|
|
@@ -11,6 +11,14 @@
|
|
|
|
|
# AGENT_ARKA_INIT 1 to run `agent-arka init --quick` when no config.toml exists (default: 1)
|
|
|
|
|
# LIBREFANG_* names for the same keys still work.
|
|
|
|
|
|
|
|
|
|
# Fail with a clear hint when piped into POSIX `sh` (dash) — this script needs
|
|
|
|
|
# bash (pipefail, [[ ]], indirect expansion). `curl … | bash`, not `| sh`.
|
|
|
|
|
if [ -z "${BASH_VERSION:-}" ]; then
|
|
|
|
|
echo "Agent Arka installer needs bash. Run:" >&2
|
|
|
|
|
echo " curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/agent-arka/install.sh | bash" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
PUBLIC_API="${AGENT_ARKA_PUBLIC_API:-https://git.arka-ai.ru/api/v1}"
|
|
|
|
@@ -149,6 +157,19 @@ ensure_path() {
|
|
|
|
|
warn "Added ${bindir} to PATH in ${rc} (open a new shell, or: source ${rc})"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Normalize a CalVer "YYYY.M.D" into a single sortable integer (YYYYMMDD pads).
|
|
|
|
|
ver_cmp_key() {
|
|
|
|
|
printf '%s' "$1" | awk -F. '{ printf "%04d%02d%02d", $1, $2, $3 }' 2>/dev/null || printf '%s' 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Installed version, or empty when there is no binary/detectable version.
|
|
|
|
|
installed_version() {
|
|
|
|
|
local bin="$1" out
|
|
|
|
|
[[ -x "$bin" ]] || return 1
|
|
|
|
|
out=$("$bin" --version 2>/dev/null | head -n 1) || return 1
|
|
|
|
|
printf '%s\n' "$out" | grep -oE '[0-9]{4}\.[0-9]+(\.[0-9]+)?' | tail -n 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main() {
|
|
|
|
|
printf '%s\n' "${C_BOLD}Agent Arka${C_RESET} — web dashboard installer"
|
|
|
|
|
command -v curl >/dev/null 2>&1 || die "curl is required"
|
|
|
|
@@ -175,6 +196,31 @@ main() {
|
|
|
|
|
info "Latest: ${version}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Update handling: detect an existing install and skip / stop / back it up.
|
|
|
|
|
local existing
|
|
|
|
|
existing=$(installed_version "${bindir}/agent-arka" 2>/dev/null || true)
|
|
|
|
|
if [[ -n "$existing" ]]; then
|
|
|
|
|
local ek tk
|
|
|
|
|
ek=$(ver_cmp_key "$existing")
|
|
|
|
|
tk=$(ver_cmp_key "$version")
|
|
|
|
|
if [[ "$ek" == "$tk" ]]; then
|
|
|
|
|
info "Already up to date: agent-arka ${existing} (target ${version})"
|
|
|
|
|
ensure_path "$bindir"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$ek" -gt "$tk" ]]; then
|
|
|
|
|
warn "Downgrading ${existing} -> ${version}"
|
|
|
|
|
else
|
|
|
|
|
info "Upgrading ${existing} -> ${version}"
|
|
|
|
|
fi
|
|
|
|
|
# Bring the running daemon down before replacing the binary.
|
|
|
|
|
if AGENT_ARKA_HOME="${HOME_DIR}" LIBREFANG_HOME="${HOME_DIR}" "${bindir}/agent-arka" stop >/dev/null 2>&1; then
|
|
|
|
|
ok "Stopped running agent-arka ${existing}"
|
|
|
|
|
fi
|
|
|
|
|
# Keep a rollback copy of the current binary.
|
|
|
|
|
cp -f "${bindir}/agent-arka" "${bindir}/agent-arka.previous" 2>/dev/null || true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local tag="${TAG_PREFIX}${version}"
|
|
|
|
|
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
|
|
|
|
local url="${PUBLIC_DL}/${tag}/${asset}"
|
|
|
|
|