diff --git a/README.md b/README.md index 5181bb3..8b02746 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ The one‑liner script will: - Install FUSE2 manually: `sudo apt-get install libfuse2` (Debian/Ubuntu), `sudo dnf install fuse` (Fedora), or `sudo pacman -S fuse2` (Arch) - Use extracted mode: `curl -fsSL https://raw.githubusercontent.com/watzon/cursor-linux-installer/main/install.sh | bash -s -- stable --extract` +If automated downloads are blocked by Cloudflare in your region, you can use one of these overrides: + +- `CURSOR_DOWNLOAD_URL= cursor-installer --update stable` +- `CURSOR_APPIMAGE_PATH=/path/to/Cursor-.AppImage cursor-installer --update stable` + ### Method 2: Local clone ```bash @@ -130,6 +135,8 @@ The uninstall script will: Note: The installer CLI is `cursor-installer` to avoid conflicts with Cursor's official `cursor` CLI. +During install, the script now removes only legacy installer-managed `~/.local/bin/cursor` scripts and leaves non-installer `cursor` executables untouched. + After installation, you can use the `cursor-installer` command to launch Cursor or update it: - To launch Cursor: `cursor-installer` diff --git a/cursor.sh b/cursor.sh index a8cc712..b8556a3 100755 --- a/cursor.sh +++ b/cursor.sh @@ -213,6 +213,69 @@ function get_download_info() { return 0 } +function downloaded_file_looks_like_appimage() { + local file_path="$1" + if [ ! -s "$file_path" ]; then + return 1 + fi + + local file_info + file_info=$(file -b "$file_path" 2>/dev/null || true) + if echo "$file_info" | grep -qiE 'HTML|XML|ASCII text|Unicode text'; then + return 1 + fi + + local first_bytes + first_bytes=$(head -c 256 "$file_path" 2>/dev/null || true) + if echo "$first_bytes" | grep -qiE '.AppImage $CLI_NAME --update stable" + log_info "You can also override the URL with CURSOR_DOWNLOAD_URL=." + return 1 +} + function clean_broken_cursor_symlinks() { local relative_path="$1" local target_root="$2" @@ -312,7 +375,7 @@ function install_cursor_extracted() { version=$(echo "$download_info" | grep "VERSION=" | sed 's/^VERSION=//') log_step "Downloading $version Cursor AppImage for extraction..." - if ! curl -L "$download_url" -o "$temp_file"; then + if ! download_cursor_appimage "$download_url" "$temp_file"; then log_error "Failed to download Cursor AppImage" rm -f "$temp_file" return 1 @@ -476,7 +539,7 @@ function install_cursor() { version=$(echo "$download_info" | grep "VERSION=" | sed 's/^VERSION=//') log_step "Downloading $version Cursor AppImage..." - if ! curl -L "$download_url" -o "$temp_file"; then + if ! download_cursor_appimage "$download_url" "$temp_file"; then log_error "Failed to download Cursor AppImage" rm -f "$temp_file" return 1 diff --git a/install.sh b/install.sh index f00d098..8929547 100755 --- a/install.sh +++ b/install.sh @@ -69,13 +69,26 @@ CLI_NAME="cursor-installer" CLI_PATH="$LOCAL_BIN/$CLI_NAME" LEGACY_CLI="$LOCAL_BIN/cursor" +function is_legacy_installer_cli() { + local file_path="$1" + if [ ! -f "$file_path" ]; then + return 1 + fi + + grep -qE 'install_cursor|check_cursor_versions|cursor\.appimage|Cursor Linux Installer' "$file_path" +} + # Create ~/.local/bin if it doesn't exist mkdir -p "$LOCAL_BIN" # Remove legacy installer CLI if present to avoid conflicts -if [ -f "$LEGACY_CLI" ] && grep -q "install_cursor_extracted" "$LEGACY_CLI"; then - log_warn "Removing legacy 'cursor' installer CLI to avoid conflicts." - safe_remove "$LEGACY_CLI" "legacy cursor installer CLI" +if [ -f "$LEGACY_CLI" ]; then + if is_legacy_installer_cli "$LEGACY_CLI"; then + log_warn "Removing legacy 'cursor' installer CLI to avoid conflicts." + safe_remove "$LEGACY_CLI" "legacy cursor installer CLI" + else + log_info "Existing '$LEGACY_CLI' does not appear installer-managed; leaving it untouched." + fi fi # Place cursor-installer CLI into ~/.local/bin from local file or GitHub @@ -112,4 +125,3 @@ else fi log_ok "Installation complete. You can now run '$CLI_NAME' to start Cursor." -