Update installer to use user-writable bin directory without sudo
Binaries / Build & Release Binaries (push) Has been cancelled

This commit is contained in:
gitea committed 2026-08-25 14:36:58 +08:00
1 parent f0d3477d69
commit 7f3a4b0fe4
1 file changed
+19 -21
+19 -21
View File
@@ -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:"