install.sh: ingen sudo (mkdir bin först; ~/.local/bin-fallback; sudo sh för system-wide)
All checks were successful
build-and-push / build (push) Successful in 10s

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 17:28:49 +02:00
parent a6e304fb53
commit 1c14a59764

View File

@@ -32,22 +32,21 @@ TAG=$(curl -fsSL "$API/releases/latest" | tr ',' '\n' | grep -m1 '"tag_name"' |
[ -n "${TAG:-}" ] || { echo "agent-helm: hittade ingen release på $BASE"; exit 1; }
URL="$BASE/$OWNER/$REPO/releases/download/$TAG/$ASSET"
# --- bin-katalog (root -> /usr/local/bin, annars sudo, annars ~/.local/bin) ---
# --- bin-katalog: /usr/local/bin om root/skrivbar, annars ~/.local/bin (ingen sudo).
# För system-wide utan att vara root: curl -fsSL ... | sudo sh
PREFIX="${PREFIX:-/usr/local}"
SUDO=""
if [ "$(id -u)" = 0 ] || [ -w "$PREFIX/bin" ]; then
if [ "$(id -u)" = 0 ] || { mkdir -p "$PREFIX/bin" 2>/dev/null && [ -w "$PREFIX/bin" ]; }; then
BIN="$PREFIX/bin"
elif command -v sudo >/dev/null 2>&1; then
BIN="$PREFIX/bin"; SUDO=sudo
else
BIN="$HOME/.local/bin"; mkdir -p "$BIN"
BIN="$HOME/.local/bin"
fi
mkdir -p "$BIN"
echo "agent-helm: hämtar $ASSET ($TAG) -> $BIN/agent-helm"
tmp=$(mktemp)
curl -fSL "$URL" -o "$tmp"
chmod +x "$tmp"
$SUDO install -m 0755 "$tmp" "$BIN/agent-helm"
install -m 0755 "$tmp" "$BIN/agent-helm"
rm -f "$tmp"
# --- config ---