Display download progress bar, source host, total file size, and explicit skill sync path in install.sh
Binaries / Build & Release Binaries (push) Has been cancelled

This commit is contained in:
gitea committed 2026-08-25 16:14:55 +08:00
1 parent 92189cc05e
commit 1674acce49
1 file changed
+83 -27
+83 -27
View File
@@ -50,47 +50,101 @@ fi
ASSET_NAME="seal-home-${PLATFORM}-${ARCH_NAME}"
TARGET_PATH="${TARGET_DIR}/seal-home"
echo "==> Downloading seal-home (${PLATFORM}-${ARCH_NAME}) into ${TARGET_DIR}..."
get_file_size() {
local file="$1"
if [ ! -f "$file" ]; then
echo "0"
return
fi
local sz
sz=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null || wc -c < "$file" | tr -d ' ')
echo "$sz"
}
format_bytes() {
local bytes="$1"
if [ -z "$bytes" ] || [ "$bytes" -le 0 ]; then
echo "0 B"
return
fi
if [ "$bytes" -ge 1048576 ]; then
awk "BEGIN {printf \"%.2f MB (%'d bytes)\", $bytes / 1048576, $bytes}" 2>/dev/null || awk "BEGIN {printf \"%.2f MB (%d bytes)\", $bytes / 1048576, $bytes}"
elif [ "$bytes" -ge 1024 ]; then
awk "BEGIN {printf \"%.2f KB (%d bytes)\", $bytes / 1024, $bytes}"
else
echo "${bytes} bytes"
fi
}
extract_host() {
local url="$1"
echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||'
}
download_candidate() {
local url="$1"
local dest="$2"
local label="$3"
local host
host="$(extract_host "$url")"
echo "==> Downloading from ${label}"
echo " Source Host: ${host}"
echo " Source URL: ${url}"
# Test connectivity & headers first
if ! curl -fIs --connect-timeout 4 "$url" >/dev/null 2>&1; then
echo " ↳ Source unreachable or asset not ready (404), falling back to next mirror..."
return 1
fi
# Download with progress bar (-# / --progress-bar)
if curl -fL --progress-bar "$url" -o "$dest"; then
local size_bytes
size_bytes="$(get_file_size "$dest")"
if [ "$size_bytes" -gt 1000000 ]; then
echo "✓ Download complete! Total size: $(format_bytes "$size_bytes")"
echo "✓ Successfully fetched from host: ${host}"
return 0
fi
fi
rm -f "$dest"
return 1
}
echo "==> Target install location: ${TARGET_PATH}"
TMP_FILE="$(mktemp)"
DOWNLOAD_SUCCESS=false
# Multi-source candidate mirrors
GITEA_BASE="https://git.ying-qing.cn/gitea/seal-home"
GITHUB_BASE="https://github.com/${REPO}"
GHPROXY_BASE="https://ghfast.top/https://github.com/${REPO}"
# Candidate mirrors
GITEA_URL="https://git.ying-qing.cn/gitea/seal-home/releases/download/latest/${ASSET_NAME}"
GITHUB_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
# 1. Check Gitea mirror if responsive
# 1. Try Gitea mirror
if [ "${SEAL_HOME_MIRROR:-auto}" = "gitea" ] || [ "${SEAL_HOME_MIRROR:-auto}" = "auto" ]; then
if curl -s --connect-timeout 2 -I "https://git.ying-qing.cn" >/dev/null 2>&1; then
GITEA_URL="${GITEA_BASE}/releases/download/latest/${ASSET_NAME}"
if curl -fL --connect-timeout 4 "$GITEA_URL" -o "$TMP_FILE" 2>/dev/null; then
echo "✓ Downloaded from high-speed mirror (git.ying-qing.cn)"
DOWNLOAD_SUCCESS=true
fi
fi
fi
# 2. Try direct GitHub
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
GITHUB_URL="${GITHUB_BASE}/releases/latest/download/${ASSET_NAME}"
if curl -fL --connect-timeout 6 "$GITHUB_URL" -o "$TMP_FILE" 2>/dev/null; then
echo "✓ Downloaded from GitHub Releases"
if download_candidate "$GITEA_URL" "$TMP_FILE" "Gitea High-Speed Mirror"; then
DOWNLOAD_SUCCESS=true
fi
fi
# 3. Fallback to GitHub CDN proxy
# 2. Try direct GitHub Releases
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
GHPROXY_URL="${GHPROXY_BASE}/releases/latest/download/${ASSET_NAME}"
echo "==> Trying CDN fallback mirror..."
if curl -fL "$GHPROXY_URL" -o "$TMP_FILE" 2>/dev/null; then
echo "✓ Downloaded from CDN mirror"
if download_candidate "$GITHUB_URL" "$TMP_FILE" "GitHub Releases (Direct)"; then
DOWNLOAD_SUCCESS=true
fi
fi
# 3. Try GitHub CDN Proxy Fallback
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
if download_candidate "$GHPROXY_URL" "$TMP_FILE" "Fast CDN Mirror (Fallback)"; then
DOWNLOAD_SUCCESS=true
fi
fi
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
echo "Error: Failed to download ${ASSET_NAME} from any available mirror." >&2
echo "Error: Failed to download ${ASSET_NAME} from all candidate mirrors." >&2
rm -f "$TMP_FILE"
exit 1
fi
@@ -100,11 +154,13 @@ mv "$TMP_FILE" "$TARGET_PATH"
# Ad-hoc sign on macOS
if [ "$PLATFORM" = "darwin" ] && command -v codesign >/dev/null 2>&1; then
echo "==> Applying macOS code signature..."
codesign --force --sign - "$TARGET_PATH" 2>/dev/null || true
fi
echo "==> Initializing agent skill..."
echo "==> Initializing AI Agent skill into ~/.agents/skills/seal-home..."
"$TARGET_PATH" skill install >/dev/null 2>&1 || true
echo "✓ Synced 9 skill and reference prompt files to ~/.agents/skills/seal-home"
echo ""
echo "✨ seal-home successfully installed to ${TARGET_PATH}!"