From 7f3a4b0fe4cdc4ebdf0c039bc3d18d519d6edcc9 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 25 Aug 2026 14:36:58 +0800 Subject: [PATCH] Update installer to use user-writable bin directory without sudo --- scripts/install.sh | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index bf0cf64..e9649d3 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,8 +2,6 @@ set -e REPO="yunyingk/seal-home" -INSTALL_DIR="/usr/local/bin" -ALT_INSTALL_DIR="$HOME/.local/bin" echo "==> Detecting platform and architecture..." OS="$(uname -s | tr '[:upper:]' '[:lower:]')" @@ -35,34 +33,34 @@ case "$ARCH" in ;; esac +# Resolve best writable bin directory without requiring sudo +TARGET_DIR="" +for candidate in "/opt/homebrew/bin" "/usr/local/bin" "$HOME/.local/bin" "$HOME/bin"; do + if [ -d "$candidate" ] && [ -w "$candidate" ]; then + TARGET_DIR="$candidate" + break + fi +done + +if [ -z "$TARGET_DIR" ]; then + mkdir -p "$HOME/.local/bin" + TARGET_DIR="$HOME/.local/bin" +fi + ASSET_NAME="seal-home-${PLATFORM}-${ARCH_NAME}" DOWNLOAD_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}" +TARGET_PATH="${TARGET_DIR}/seal-home" -echo "==> Downloading latest seal-home for ${PLATFORM}-${ARCH_NAME}..." +echo "==> Downloading seal-home (${PLATFORM}-${ARCH_NAME}) into ${TARGET_DIR}..." TMP_FILE="$(mktemp)" -if ! curl -fsSL "$DOWNLOAD_URL" -o "$TMP_FILE"; then +if ! curl -fL "$DOWNLOAD_URL" -o "$TMP_FILE"; then echo "Error: Failed to download $DOWNLOAD_URL" >&2 rm -f "$TMP_FILE" exit 1 fi chmod +x "$TMP_FILE" - -# Determine target directory -TARGET_PATH="${INSTALL_DIR}/seal-home" -if [ -w "$INSTALL_DIR" ]; then - mv "$TMP_FILE" "$TARGET_PATH" -elif command -v sudo >/dev/null 2>&1; then - echo "==> Installing to ${TARGET_PATH} (requires sudo)..." - sudo mv "$TMP_FILE" "$TARGET_PATH" - sudo chmod 755 "$TARGET_PATH" -else - mkdir -p "$ALT_INSTALL_DIR" - TARGET_PATH="${ALT_INSTALL_DIR}/seal-home" - mv "$TMP_FILE" "$TARGET_PATH" - echo "==> Installed to ${TARGET_PATH}" - echo " Please ensure ${ALT_INSTALL_DIR} is in your PATH." -fi +mv "$TMP_FILE" "$TARGET_PATH" # Ad-hoc sign on macOS if [ "$PLATFORM" = "darwin" ] && command -v codesign >/dev/null 2>&1; then @@ -73,7 +71,7 @@ echo "==> Initializing agent skill..." "$TARGET_PATH" skill install >/dev/null 2>&1 || true echo "" -echo "✨ seal-home successfully installed!" +echo "✨ seal-home successfully installed to ${TARGET_PATH}!" "$TARGET_PATH" version echo "" echo "Quick start:"