Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$ErrorActionPreference = 'Stop'

$ARCH = $env:PROCESSOR_ARCHITECTURE

switch -Regex ($ARCH) {
"AMD64" { $ARCH_NAME = "x86_64" }
"x86" { $ARCH_NAME = "i686" }
"ARM64" { $ARCH_NAME = "aarch64" }
default {
Write-Host "❌ Error: Unsupported Architecture: $ARCH"
exit 1
}
}

$BASE_URL = "https://fast-down-update.s121.top/cli/download/latest"
$DOWNLOAD_URL = "$BASE_URL/windows/$ARCH_NAME"

# Idiomatic Windows user-level installation path
$INSTALL_DIR = "$env:LOCALAPPDATA\Programs\fast-down"
$BIN_NAME = "fast-down.exe"
$TMP_FILE = [System.IO.Path]::GetTempFileName()

Write-Host "Downloading $DOWNLOAD_URL ..."
try {
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $TMP_FILE -UseBasicParsing
} catch {
Write-Host "❌ Error: Failed to download the file."
Remove-Item -Path $TMP_FILE -ErrorAction SilentlyContinue
exit 1
}

if (-not (Test-Path -Path $INSTALL_DIR)) {
New-Item -ItemType Directory -Force -Path $INSTALL_DIR | Out-Null
}

Move-Item -Path $TMP_FILE -Destination "$INSTALL_DIR\$BIN_NAME" -Force

Write-Host "🎉 Installed to $INSTALL_DIR\$BIN_NAME"

# Check if the install directory is in the PATH
if (($env:PATH -split ';') -notcontains $INSTALL_DIR) {
Write-Host "⚠️ Note: You need to add $INSTALL_DIR to your PATH environment variable."
Write-Host " You can do this by searching for 'Edit environment variables for your account' in the Start menu."
} else {
Write-Host "🚀 You can now run 'fast-down' from your terminal!"
}
57 changes: 57 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

set -e

OS="$(uname -s)"
ARCH="$(uname -m)"

case "$OS" in
Linux*) OS_NAME="linux" ;;
Darwin*) OS_NAME="macos" ;;
*) echo "❌ Error: Unsupported OS: $OS. This script only supports Linux and macOS."; exit 1 ;;
esac

case "$ARCH" in
x86_64|amd64) ARCH_NAME="x86_64" ;;
i386|i686|x86) ARCH_NAME="i686" ;;
aarch64|arm64|armv8) ARCH_NAME="aarch64" ;;
*) echo "❌ Error: Unsupported Architecture: $ARCH"; exit 1 ;;
esac

if [ "$OS_NAME" = "macos" ]; then
if [ "$ARCH_NAME" != "aarch64" ] && [ "$ARCH_NAME" != "x86_64" ]; then
echo "❌ Error: Unsupported architecture for macOS: $ARCH_NAME. Only aarch64 and x86_64 are supported."
exit 1
fi
fi

BASE_URL="https://fast-down-update.s121.top/cli/download/latest"
DOWNLOAD_URL="${BASE_URL}/${OS_NAME}/${ARCH_NAME}"

INSTALL_DIR="$HOME/.local/bin"
BIN_NAME="fast-down"
TMP_FILE=$(mktemp)

# 5. Download the binary
echo "Downloading $DOWNLOAD_URL ..."
if command -v curl >/dev/null 2>&1; then
curl -# -L -o "$TMP_FILE" "$DOWNLOAD_URL"
elif command -v wget >/dev/null 2>&1; then
wget -q --show-progress -O "$TMP_FILE" "$DOWNLOAD_URL"
else
echo "❌ Error: curl or wget is required to download the file."
rm -f "$TMP_FILE"
exit 1
fi

chmod +x "$TMP_FILE"
mkdir -p "$INSTALL_DIR"
mv "$TMP_FILE" "$INSTALL_DIR/$BIN_NAME"

echo "🎉 Installed to $INSTALL_DIR/$BIN_NAME"

if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo "⚠️ Note: You may need to add $INSTALL_DIR to your PATH in your ~/.bashrc or ~/.zshrc."
else
echo "🚀 You can now run '$BIN_NAME' from your terminal!"
fi
Loading