- CLI Rust (am) : list/install/uninstall/update/start/stop/restart/run/status/search/info/config/doctor/completion/export/import/self-update + shell interactif (Tab, historique) - 9 methodes d'installation (npm, pip, uv, cargo, go, bun, curl, binary, git) - catalogue de 72 agents, dependances, processus, securite (dry-run, checksums) - sondes de version paralleles + cache (am list ~25 ms a chaud) - installateurs one-liner : install.sh, install.ps1
84 lines
2.7 KiB
Bash
84 lines
2.7 KiB
Bash
#!/bin/sh
|
|
# agent-manager (am) — installateur Linux / macOS / WSL
|
|
#
|
|
# One-liner :
|
|
# curl -fsSL https://git.dracodev.net/Projets/agent-manager/raw/branch/main/install.sh | sh
|
|
#
|
|
# Télécharge le binaire de la dernière release Gitea ; à défaut, compile via
|
|
# cargo install --git. Relancez le script pour mettre à jour.
|
|
set -eu
|
|
|
|
BASE_URL="${AM_BASE_URL:-https://git.dracodev.net/Projets/agent-manager}"
|
|
API_URL="${AM_API_URL:-https://git.dracodev.net/api/v1/repos/Projets/agent-manager}"
|
|
INSTALL_DIR="${AM_INSTALL_DIR:-$HOME/.local/bin}"
|
|
GIT_URL="$BASE_URL.git"
|
|
|
|
fail() { echo "erreur: $1" >&2; exit 1; }
|
|
|
|
arch=$(uname -m)
|
|
case "$arch" in
|
|
x86_64|amd64) arch="x86_64" ;;
|
|
aarch64|arm64) arch="aarch64" ;;
|
|
*) fail "architecture non supportée: $arch" ;;
|
|
esac
|
|
|
|
install_from_source() {
|
|
if ! command -v cargo >/dev/null 2>&1; then
|
|
fail "pas de binaire précompilé pour $arch et cargo est absent — installez Rust (https://rustup.rs) puis relancez"
|
|
fi
|
|
echo "Installation depuis les sources (cargo install --git $GIT_URL)…"
|
|
cargo install --git "$GIT_URL" --locked
|
|
echo ""
|
|
echo "OK — am est installé dans ~/.cargo/bin/am"
|
|
echo "Essayez : am list | am doctor (mise à jour : relancez ce script)"
|
|
exit 0
|
|
}
|
|
|
|
tmpdir=$(mktemp -d)
|
|
trap 'rm -rf "$tmpdir"' EXIT
|
|
|
|
tag=""
|
|
if command -v curl >/dev/null 2>&1; then
|
|
release=$(curl -fsSL --connect-timeout 15 "$API_URL/releases/latest" 2>/dev/null || true)
|
|
tag=$(printf '%s' "$release" | grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -n 1 | cut -d'"' -f4)
|
|
fi
|
|
|
|
installed=""
|
|
if [ -n "$tag" ] && command -v curl >/dev/null 2>&1; then
|
|
asset="am-linux-$arch.tar.gz"
|
|
url="$BASE_URL/releases/download/$tag/$asset"
|
|
echo "Téléchargement de $url …"
|
|
if curl -fsSL --connect-timeout 20 -o "$tmpdir/am.tar.gz" "$url"; then
|
|
tar -xzf "$tmpdir/am.tar.gz" -C "$tmpdir" 2>/dev/null || true
|
|
if [ -f "$tmpdir/am" ]; then
|
|
mkdir -p "$INSTALL_DIR"
|
|
cp "$tmpdir/am" "$INSTALL_DIR/am"
|
|
chmod +x "$INSTALL_DIR/am"
|
|
installed=1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$installed" ]; then
|
|
echo "Binaire précompilé indisponible — installation depuis les sources…"
|
|
install_from_source
|
|
fi
|
|
|
|
case ":$PATH:" in
|
|
*":$INSTALL_DIR:"*) ;;
|
|
*)
|
|
echo "Astuce : $INSTALL_DIR n'est pas dans votre PATH"
|
|
if [ -f "$HOME/.profile" ] && ! grep -qF "$INSTALL_DIR" "$HOME/.profile"; then
|
|
echo "export PATH="$INSTALL_DIR:\$PATH"" >> "$HOME/.profile"
|
|
echo "Ajouté à ~/.profile (reconnectez-vous pour en profiter)"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
"$INSTALL_DIR/am" --version || true
|
|
echo ""
|
|
echo "OK — 'am' est installé. Essayez :"
|
|
echo " am list"
|
|
echo " am doctor"
|
|
echo "Mise à jour : relancez ce script."
|