-
-
Save alsyundawy/aaf8e431e566bb22c0ddfb1ba4caf968 to your computer and use it in GitHub Desktop.
Direct Download VMWare Fusion - Download, Install, and Update VMWare Fusion Automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # VMware Fusion Latest Version Downloader, Installer, and Updater | |
| # This script automatically finds, downloads, and optionally installs the highest version available | |
| # | |
| # Inspired by: https://gist.github.com/jetfir3/6b28fd279bbcadbae70980bd711a844f | |
| # | |
| # Usage: $0 [-y] [-i] [-d] [-f] [-t <dmg_path>] | |
| # -y: Skip download confirmation prompt | |
| # -i: Automatically install after download (implies -y) | |
| # -d: Download only (skip installation even if -i is specified) | |
| # -f: Force update even if same version is installed | |
| # -t: Test installation with existing DMG file (skips download) | |
| ARCHIVE_BASE_URL="https://archive.org/download/vmwareworkstationarchive/Fusion" | |
| SKIP_CONFIRMATION=false | |
| AUTO_INSTALL=false | |
| DOWNLOAD_ONLY=false | |
| FORCE_UPDATE=false | |
| TEST_DMG="" | |
| VERSION_FILE="${HOME}/.local/.vmwarefusion_last_version" | |
| DOWNLOAD_DIR="${HOME}/Downloads" # FIX: dipindah ke scope global (sebelumnya hanya di dalam main()) | |
| # FIX: SORT_CMD dan SORT_UNIQUE_CMD dijadikan array kosong di scope global | |
| # Sebelumnya berupa string yang menyebabkan SC2086 (word splitting) saat dipakai sebagai command | |
| SORT_CMD=() | |
| SORT_UNIQUE_CMD=() | |
| usage() { | |
| echo "Usage: $0 [-y] [-i] [-d] [-f] [-t <dmg_path>]" | |
| echo " -y: Skip download confirmation prompt" | |
| echo " -i: Automatically install after download (implies -y)" | |
| echo " -d: Download only (skip installation even if -i is specified)" | |
| echo " -f: Force update even if same version is installed" | |
| echo " -t: Test installation with existing DMG file (skips download)" | |
| echo # FIX: echo "" → echo (tidak perlu argumen kosong) | |
| echo "Examples:" | |
| echo " $0 # Interactive download" | |
| echo " $0 -i # Auto download + install (or update if newer)" | |
| echo " $0 -i -f # Force install even if same version" | |
| echo " $0 -t ~/Downloads/VMware-Fusion-13.6.4.dmg # Test install existing DMG" | |
| exit 1 | |
| } | |
| while getopts "yidft:" opt; do | |
| case $opt in | |
| y) SKIP_CONFIRMATION=true ;; | |
| i) AUTO_INSTALL=true; SKIP_CONFIRMATION=true ;; | |
| d) DOWNLOAD_ONLY=true ;; | |
| f) FORCE_UPDATE=true ;; | |
| t) TEST_DMG="$OPTARG"; AUTO_INSTALL=true; SKIP_CONFIRMATION=true ;; | |
| *) usage ;; | |
| esac | |
| done | |
| requirements_check() { | |
| local cmd # FIX: SC2155 — deklarasi local terpisah dari assignment | |
| for cmd in curl grep awk sed sort; do | |
| # FIX: ganti { ... } dengan if/fi agar lebih readable dan menghindari SC2166 | |
| if ! command -v "$cmd" >/dev/null 2>&1; then | |
| echo "Error: $cmd is required but not installed." >&2 | |
| exit 1 | |
| fi | |
| done | |
| # FIX: ganti "if $AUTO_INSTALL && ! $DOWNLOAD_ONLY" → perbandingan string eksplisit (SC2235) | |
| if [[ "$AUTO_INSTALL" == "true" && "$DOWNLOAD_ONLY" != "true" ]]; then | |
| for cmd in hdiutil cp; do | |
| if ! command -v "$cmd" >/dev/null 2>&1; then | |
| echo "Error: $cmd is required for installation but not found." >&2 | |
| exit 1 | |
| fi | |
| done | |
| fi | |
| } | |
| setup_sort() { | |
| if sort --version 2>/dev/null | grep -q "GNU coreutils"; then | |
| # FIX: SORT_CMD dan SORT_UNIQUE_CMD dijadikan array, bukan string | |
| # Sebelumnya: SORT_CMD="sort -V" — menyebabkan SC2086 saat dipakai sebagai command | |
| SORT_CMD=(sort -V) | |
| SORT_UNIQUE_CMD=(sort -uV) | |
| else | |
| SORT_CMD=(sort -t. -k1,1n -k2,2n -k3,3n -k4,4n) | |
| SORT_UNIQUE_CMD=(sort -t. -k1,1n -k2,2n -k3,3n -k4,4n -u) | |
| fi | |
| } | |
| get_archive_major_versions() { | |
| local html | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| # Sebelumnya: local html=$(curl ...) | |
| # Pola if ! cmd; then ... fi lebih bersih dari mengecek $? setelah assignment | |
| if ! html=$(curl -s -f -L --max-time 30 "$ARCHIVE_BASE_URL/" 2>/dev/null); then | |
| echo "Error: Failed to fetch archive.org page." >&2 | |
| echo "The main VMware Fusion archive may be unavailable." >&2 | |
| echo >&2 | |
| echo "Check source availability:" >&2 | |
| echo " https://archive.org/details/vmwareworkstationarchive" >&2 | |
| echo >&2 | |
| echo "Or look for a new source:" >&2 | |
| echo " https://archive.org/search?query=VMware+Fusion&sort=-addeddate" >&2 | |
| exit 1 | |
| fi | |
| if [[ -z "$html" ]]; then | |
| echo "Error: Empty response from archive.org." >&2 | |
| exit 1 | |
| fi | |
| # FIX: double backslash (\\) di grep/sed diperbaiki menjadi single backslash | |
| # Sebelumnya ter-escape karena copas dari markdown: | |
| # grep -o '<a href="\\([0-9][^"/]*\\/\\)"' | |
| # sed 's/<a href="\\([^"]*\\)".*/\\1/' | |
| echo "$html" \ | |
| | grep -o '<a href="[0-9][^"/]*/"' \ | |
| | sed 's/<a href="\([^"]*\)".*/\1/' \ | |
| | sed 's|/$||' \ | |
| | "${SORT_UNIQUE_CMD[@]}" # FIX: array expansion "${SORT_UNIQUE_CMD[@]}" bukan $SORT_UNIQUE_CMD | |
| } | |
| get_archive_full_versions() { | |
| local major_version="$1" | |
| local html | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| html=$(curl -s -f -L --max-time 30 "$ARCHIVE_BASE_URL/$major_version/" 2>/dev/null) || return 1 | |
| echo "$html" \ | |
| | grep -o '<a href="VMware-Fusion-[^"]*\.dmg"' \ | |
| # FIX: double backslash di sed diperbaiki → single backslash | |
| | sed 's/<a href="\([^"]*\)".*/\1/' \ | |
| | while IFS= read -r filename; do | |
| # FIX: [[ =~ ]] regex: double backslash \\. → single \. (literal dot) | |
| # Sebelumnya: VMware-Fusion-([0-9]+\\.[0-9]+\\.[0-9]+) — salah karena \\. = backslash + any char | |
| if [[ $filename =~ VMware-Fusion-([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
| echo "${BASH_REMATCH[1]} $filename $major_version" | |
| fi | |
| done \ | |
| | "${SORT_CMD[@]}" # FIX: array expansion "${SORT_CMD[@]}" bukan $SORT_CMD | |
| } | |
| find_latest_version() { | |
| local all_entries=() | |
| local major_versions | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| major_versions=$(get_archive_major_versions) | |
| if [[ -z "$major_versions" ]]; then | |
| echo "Error: No major versions found on archive.org." >&2 | |
| exit 1 | |
| fi | |
| local major_version version filename major_ver # FIX: semua variabel loop dideklarasikan sekaligus | |
| while IFS= read -r major_version; do | |
| [[ -z "$major_version" ]] && continue | |
| while IFS=' ' read -r version filename major_ver; do | |
| # FIX: regex dalam [[ =~ ]] diperbaiki dari double backslash ke single backslash | |
| if [[ -n "$version" && -n "$filename" && "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| all_entries+=("$version|$filename|$major_ver") | |
| fi | |
| done < <(get_archive_full_versions "$major_version" 2>/dev/null) | |
| done <<< "$major_versions" | |
| if [[ ${#all_entries[@]} -eq 0 ]]; then | |
| echo "Error: No versions found on archive.org." >&2 | |
| exit 1 | |
| fi | |
| local highest_entry="" highest_version="" entry current_version | |
| for entry in "${all_entries[@]}"; do | |
| IFS='|' read -r current_version _ _ <<< "$entry" | |
| if [[ -z "$highest_version" ]] || version_greater_than "$current_version" "$highest_version"; then | |
| highest_version="$current_version" | |
| highest_entry="$entry" | |
| fi | |
| done | |
| echo "$highest_entry" | |
| } | |
| get_installed_version() { | |
| if [[ -d "/Applications/VMware Fusion.app" ]]; then | |
| # FIX: SC2155 — return value dari defaults read tidak dimasking oleh local | |
| defaults read "/Applications/VMware Fusion.app/Contents/Info.plist" \ | |
| CFBundleShortVersionString 2>/dev/null || true | |
| fi | |
| } | |
| get_stored_version() { | |
| if [[ -f "$VERSION_FILE" ]]; then | |
| cat "$VERSION_FILE" 2>/dev/null || true | |
| fi | |
| } | |
| store_version() { | |
| local version="$1" | |
| local build="$2" | |
| mkdir -p "$(dirname "$VERSION_FILE")" | |
| echo "${version}-${build}" > "$VERSION_FILE" | |
| } | |
| extract_build_from_filename() { | |
| local filename="$1" | |
| # FIX: regex diperbaiki — double backslash \\. → single \. | |
| if [[ $filename =~ VMware-Fusion-[0-9]+\.[0-9]+\.[0-9]+-([0-9]+) ]]; then | |
| echo "${BASH_REMATCH[1]}" | |
| else | |
| echo "unknown" | |
| fi | |
| } | |
| check_update_needed() { | |
| local latest_version="$1" | |
| local latest_filename="$2" | |
| local latest_build | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| latest_build=$(extract_build_from_filename "$latest_filename") | |
| local latest_full="${latest_version}-${latest_build}" | |
| echo "=== Version Check ===" | |
| local installed_version | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| installed_version=$(get_installed_version) | |
| if [[ -z "$installed_version" ]]; then | |
| echo "VMware Fusion: Not installed" | |
| echo "Latest available: $latest_full" | |
| echo "Action: Install" | |
| return 0 | |
| fi | |
| local stored_version | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| stored_version=$(get_stored_version) | |
| echo "Installed version: $installed_version" | |
| [[ -n "$stored_version" ]] && echo "Last installed: $stored_version" | |
| echo "Latest available: $latest_full" | |
| # FIX: ganti "if $FORCE_UPDATE" → perbandingan string eksplisit (SC2235) | |
| if [[ "$FORCE_UPDATE" == "true" ]]; then | |
| echo "Action: Force update (requested)" | |
| return 0 | |
| fi | |
| if [[ "$stored_version" == "$latest_full" ]]; then | |
| echo "Action: Up to date (same version-build)" | |
| return 1 | |
| elif version_greater_than "$latest_version" "$installed_version"; then | |
| echo "Action: Update (newer version available)" | |
| return 0 | |
| elif [[ "$latest_version" == "$installed_version" && "$stored_version" != "$latest_full" ]]; then | |
| echo "Action: Update (same version, different build)" | |
| return 0 | |
| else | |
| echo "Action: Up to date" | |
| return 1 | |
| fi | |
| } | |
| version_greater_than() { | |
| local version1="$1" | |
| local version2="$2" | |
| local v1_parts v2_parts | |
| IFS='.' read -ra v1_parts <<< "$version1" | |
| IFS='.' read -ra v2_parts <<< "$version2" | |
| local i | |
| # FIX: ganti "for i in {0..2}" dengan explicit list agar lebih portable | |
| for i in 0 1 2; do | |
| local v1_part="${v1_parts[$i]:-0}" | |
| local v2_part="${v2_parts[$i]:-0}" | |
| # FIX: ganti [ $v1 -gt $v2 ] → (( )) untuk aritmatika integer (lebih bersih) | |
| if (( v1_part > v2_part )); then | |
| return 0 | |
| elif (( v1_part < v2_part )); then | |
| return 1 | |
| fi | |
| done | |
| return 1 | |
| } | |
| download_vmware_fusion() { | |
| local major_version="$1" | |
| local filename="$2" | |
| local version="$3" | |
| local download_url="$ARCHIVE_BASE_URL/$major_version/$filename" | |
| local download_file="$DOWNLOAD_DIR/$filename" | |
| local max_retries=3 | |
| local retry_delay=5 | |
| local attempt=1 | |
| echo "Downloading VMware Fusion $version..." | |
| echo "From: $download_url" | |
| echo "To: $download_file" | |
| echo # FIX: echo "" → echo | |
| # FIX: ganti "while [ $attempt -le $max_retries ]" → (( )) untuk aritmatika | |
| while (( attempt <= max_retries )); do | |
| echo "Attempt $attempt of $max_retries..." | |
| # FIX: ganti "[ $attempt -gt 1 ]" → (( )) untuk aritmatika | |
| if (( attempt > 1 )) && [[ -f "$download_file" ]]; then | |
| echo "Resuming partial download..." | |
| fi | |
| if curl -k -q --progress-bar -f -L -C - --max-time 300 -o "$download_file" "$download_url"; then | |
| # FIX: ganti "echo -e '\nDownload successful!'" → printf (SC2028: echo -e tidak portable) | |
| printf '\nDownload successful!\n' | |
| return 0 | |
| else | |
| echo "Attempt $attempt failed." >&2 | |
| # FIX: ganti "[ $attempt -lt $max_retries ]" → (( )) | |
| if (( attempt < max_retries )); then | |
| echo "Retrying in $retry_delay seconds..." | |
| sleep "$retry_delay" | |
| fi | |
| fi | |
| # FIX: ganti "((attempt++))" → aritmatika assignment yang aman | |
| # ((attempt++)) bisa return exit code 1 jika nilai = 0, berbahaya dengan set -e | |
| attempt=$(( attempt + 1 )) | |
| done | |
| echo "Error: Download failed after $max_retries attempts." >&2 | |
| exit 1 | |
| } | |
| # FIX: FUNGSI BARU — show_license_info() ditambahkan | |
| # Sebelumnya fungsi ini dipanggil di beberapa tempat tapi tidak pernah didefinisikan (undefined function) | |
| show_license_info() { | |
| echo | |
| echo "License keys (community):" | |
| echo " https://github.com/hegdepavankumar/VMware-Workstation-Pro-17-Licence-Keys" | |
| } | |
| install_vmware_fusion() { | |
| local dmg_file="$1" | |
| local version="$2" | |
| local filename="$3" | |
| echo | |
| echo "Starting VMware Fusion Installation" | |
| echo "===================================" | |
| if [[ ! -f "$dmg_file" ]]; then | |
| echo "Error: DMG file not found: $dmg_file" | |
| return 1 | |
| fi | |
| if [[ -d "/Applications/VMware Fusion.app" ]]; then | |
| local current_version | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| current_version=$(defaults read "/Applications/VMware Fusion.app/Contents/Info.plist" \ | |
| CFBundleShortVersionString 2>/dev/null || echo "Unknown") | |
| echo "Current VMware Fusion version: $current_version" | |
| echo "Will replace with version: $version" | |
| echo | |
| fi | |
| echo "Mounting DMG file..." | |
| local mount_output | |
| # FIX: SC2155 + ganti cek $? → gunakan "if ! cmd; then" secara langsung | |
| # Sebelumnya: | |
| # mount_output=$(hdiutil attach ...) | |
| # local mount_result=$? | |
| # if [[ $mount_result -ne 0 ]]; then ... | |
| if ! mount_output=$(hdiutil attach "$dmg_file" -nobrowse 2>&1); then | |
| echo "Error: Failed to mount DMG file." | |
| echo "hdiutil error output: $mount_output" | |
| return 1 | |
| fi | |
| echo "Debug - Mount output:" | |
| echo "$mount_output" | |
| echo "---" | |
| local mount_point="" | |
| # Method 1: tab-separated hdiutil output (3rd column) | |
| # FIX: awk -F'\\t' → -F'\t' (double backslash salah, menghasilkan literal \t bukan tab) | |
| mount_point=$(echo "$mount_output" | grep '/Volumes/' | awk -F'\t' '{print $3}' | head -1) | |
| echo "Method 1 mount point (tab-separated): '$mount_point'" | |
| # Method 2: trailing path after last whitespace block | |
| if [[ -z "$mount_point" ]]; then | |
| # FIX: sed dengan double backslash (\\+, \\() diperbaiki ke single backslash | |
| mount_point=$(echo "$mount_output" | grep '/Volumes/' \ | |
| | sed 's/.*[[:space:]]\(\/Volumes\/.*\)$/\1/' | head -1) | |
| echo "Method 2 mount point (space-separated): '$mount_point'" | |
| fi | |
| # FIX: Method 3 mengganti "ls /Volumes/ | grep" → loop glob (SC2012: jangan parse output ls) | |
| # Sebelumnya: possible_mounts=$(ls /Volumes/ | grep -i "vmware\|fusion" | head -1) | |
| if [[ -z "$mount_point" ]]; then | |
| local vol | |
| for vol in /Volumes/*; do | |
| if echo "$vol" | grep -iq "vmware\|fusion"; then | |
| mount_point="$vol" | |
| echo "Method 3 mount point (glob): '$mount_point'" | |
| break | |
| fi | |
| done | |
| fi | |
| if [[ -z "$mount_point" ]]; then | |
| echo "Error: Could not determine mount point from hdiutil output." | |
| echo "All parsing methods failed." | |
| echo "Raw output lines:" | |
| cat -n <<< "$mount_output" | |
| # FIX: ganti while read setelah pipe (subshell) → process substitution < <(...) | |
| while IFS= read -r device; do | |
| echo "Attempting to detach device: $device" | |
| hdiutil detach "$device" -quiet 2>/dev/null || true | |
| done < <(echo "$mount_output" | grep '/dev/' | awk '{print $1}') | |
| return 1 | |
| fi | |
| echo "Mounted at: $mount_point" | |
| local fusion_app | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| fusion_app=$(find "$mount_point" -name "VMware Fusion.app" -type d | head -1) | |
| if [[ -z "$fusion_app" ]]; then | |
| echo "Error: VMware Fusion.app not found in DMG." | |
| hdiutil detach "$mount_point" -quiet | |
| return 1 | |
| fi | |
| echo "Found: $fusion_app" | |
| local dmg_version | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| dmg_version=$(defaults read "$fusion_app/Contents/Info.plist" \ | |
| CFBundleShortVersionString 2>/dev/null || echo "Unknown") | |
| echo "Version in DMG: $dmg_version" | |
| if [[ -d "/Applications/VMware Fusion.app" ]]; then | |
| echo "Removing existing VMware Fusion installation..." | |
| # FIX: ganti "rm ...; if [[ $? -ne 0 ]]" → "if ! rm ..." | |
| if ! rm -rf "/Applications/VMware Fusion.app"; then | |
| echo "Error: Failed to remove existing installation. You may need sudo privileges." | |
| hdiutil detach "$mount_point" -quiet | |
| return 1 | |
| fi | |
| fi | |
| echo "Installing VMware Fusion..." | |
| # FIX: ganti "cp ...; if [[ $? -ne 0 ]]" → "if ! cp ..." | |
| if ! cp -R "$fusion_app" "/Applications/"; then | |
| echo "Error: Failed to copy application. You may need sudo privileges." | |
| hdiutil detach "$mount_point" -quiet | |
| return 1 | |
| fi | |
| echo "Removing quarantine attribute..." | |
| xattr -dr com.apple.quarantine "/Applications/VMware Fusion.app" 2>/dev/null || true | |
| echo "Cleaning up..." | |
| # FIX: ganti "hdiutil detach; if [[ $? -ne 0 ]]" → "if ! hdiutil detach ..." | |
| if ! hdiutil detach "$mount_point" -quiet; then | |
| echo "Warning: Failed to unmount DMG. It may still be mounted at $mount_point" | |
| fi | |
| if [[ -d "/Applications/VMware Fusion.app" ]]; then | |
| local installed_version | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| installed_version=$(defaults read "/Applications/VMware Fusion.app/Contents/Info.plist" \ | |
| CFBundleShortVersionString 2>/dev/null || echo "Unknown") | |
| echo | |
| echo "Installation completed successfully!" | |
| echo "VMware Fusion $installed_version installed to /Applications/" | |
| if [[ -n "$filename" ]]; then | |
| local build_number | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| build_number=$(extract_build_from_filename "$filename") | |
| store_version "$installed_version" "$build_number" | |
| echo "Version info stored: ${installed_version}-${build_number}" | |
| fi | |
| return 0 | |
| else | |
| echo "Installation failed!" | |
| return 1 | |
| fi | |
| } | |
| main() { | |
| echo "VMware Fusion Latest Version Downloader & Installer" | |
| echo "====================================================" | |
| requirements_check | |
| if [[ -n "$TEST_DMG" ]]; then | |
| if [[ ! -f "$TEST_DMG" ]]; then | |
| echo "Error: Test DMG file not found: $TEST_DMG" | |
| exit 1 | |
| fi | |
| echo "Test Mode: Installing existing DMG" | |
| echo "DMG File: $TEST_DMG" | |
| echo | |
| local dmg_filename test_version # FIX: SC2155 — deklarasi terpisah | |
| dmg_filename=$(basename "$TEST_DMG") | |
| test_version="Unknown" | |
| # FIX: regex diperbaiki — double backslash → single backslash | |
| if [[ $dmg_filename =~ VMware-Fusion-([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
| test_version="${BASH_REMATCH[1]}" | |
| fi | |
| if [[ $(uname) != "Darwin" ]]; then | |
| echo "Error: Installation is only supported on macOS." | |
| exit 1 | |
| fi | |
| if install_vmware_fusion "$TEST_DMG" "$test_version" "$dmg_filename"; then | |
| echo | |
| echo "You can now launch VMware Fusion from /Applications/ or Spotlight." | |
| show_license_info # FIX: fungsi ini kini terdefinisi (lihat show_license_info di atas) | |
| else | |
| echo "Installation failed." | |
| exit 1 | |
| fi | |
| exit 0 | |
| fi | |
| setup_sort | |
| mkdir -p "${DOWNLOAD_DIR}" | |
| echo "Scanning archive.org for the latest version..." | |
| local result | |
| # FIX: SC2155 — pisahkan deklarasi local dari command substitution | |
| result=$(find_latest_version) | |
| if [[ -z "$result" || "$result" == *"Error:"* ]]; then | |
| echo "Error: Could not determine the latest version." >&2 | |
| exit 1 | |
| fi | |
| local latest_version latest_filename latest_major_version | |
| IFS='|' read -r latest_version latest_filename latest_major_version <<< "$result" | |
| if [[ -z "$latest_version" || -z "$latest_filename" || -z "$latest_major_version" ]]; then | |
| echo "Error: Could not parse version information." >&2 | |
| echo "Debug: result='$result'" >&2 | |
| exit 1 | |
| fi | |
| echo | |
| echo "Latest version found: VMware Fusion $latest_version" | |
| # FIX: ganti inline ternary if/echo menjadi if/fi block standar | |
| if [[ $latest_version =~ ^1[3-9]\. ]]; then | |
| echo "Architecture: Universal" | |
| else | |
| echo "Architecture: x86_64" | |
| fi | |
| echo "File: $latest_filename" | |
| echo "Major version folder: $latest_major_version" | |
| # FIX: ganti "if $AUTO_INSTALL && ! $DOWNLOAD_ONLY" → perbandingan string (SC2235) | |
| if [[ "$AUTO_INSTALL" == "true" && "$DOWNLOAD_ONLY" != "true" ]]; then | |
| echo "Mode: Download + Install" | |
| else | |
| echo "Mode: Download Only" | |
| fi | |
| echo | |
| # FIX: HAPUS BLOK DUPLIKAT — check_update_needed() dipanggil 2x di kode asli | |
| # Blok kedua yang identis dihapus sepenuhnya | |
| # FIX: ganti "if ! $DOWNLOAD_ONLY" → perbandingan string eksplisit | |
| if [[ "$DOWNLOAD_ONLY" != "true" ]]; then | |
| if ! check_update_needed "$latest_version" "$latest_filename"; then | |
| # FIX: ganti "if ! $SKIP_CONFIRMATION" → perbandingan string eksplisit | |
| if [[ "$SKIP_CONFIRMATION" != "true" ]]; then | |
| read -r -p "VMware Fusion is up to date. Download anyway? (y/N): " confirm | |
| case "$confirm" in | |
| [yY]|[yY][eE][sS]) echo "Proceeding with download..." ;; | |
| *) echo "Operation cancelled."; exit 0 ;; | |
| esac | |
| else | |
| echo "VMware Fusion is up to date. Use -f to force update." | |
| exit 0 | |
| fi | |
| fi | |
| fi | |
| echo | |
| # FIX: HAPUS variabel "skip_due_to_version=false" yang dideklarasikan tapi tidak pernah dipakai (SC2034) | |
| local dmg_path="${DOWNLOAD_DIR}/${latest_filename}" | |
| local need_download=true | |
| if [[ -f "$dmg_path" ]]; then | |
| echo "File already exists: $dmg_path" | |
| if [[ "$SKIP_CONFIRMATION" != "true" ]]; then | |
| read -r -p "Re-download VMware Fusion $latest_version? (y/N): " confirm | |
| case "$confirm" in | |
| [yY]|[yY][eE][sS]) need_download=true ;; | |
| *) need_download=false; echo "Using existing file." ;; | |
| esac | |
| else | |
| need_download=false | |
| echo "Using existing file (auto mode)." | |
| fi | |
| fi | |
| # FIX: ganti "if $need_download" → perbandingan string eksplisit | |
| if [[ "$need_download" == "true" ]]; then | |
| if [[ "$SKIP_CONFIRMATION" != "true" ]]; then | |
| read -r -p "Download VMware Fusion $latest_version? (y/N): " confirm | |
| case "$confirm" in | |
| [yY]|[yY][eE][sS]) echo "Starting download..." ;; | |
| *) echo "Download cancelled."; exit 0 ;; | |
| esac | |
| else | |
| echo "Auto-downloading VMware Fusion $latest_version..." | |
| fi | |
| download_vmware_fusion "$latest_major_version" "$latest_filename" "$latest_version" | |
| if [[ $(uname) == "Darwin" ]]; then | |
| echo "Removing quarantine attribute from DMG..." | |
| # FIX: &>/dev/null → 2>/dev/null (lebih portable, &> adalah bashism yang tidak selalu aman) | |
| xattr -d com.apple.quarantine "$dmg_path" 2>/dev/null || true | |
| fi | |
| fi | |
| echo | |
| echo "Download completed successfully!" | |
| echo "File location: $dmg_path" | |
| if [[ "$AUTO_INSTALL" == "true" && "$DOWNLOAD_ONLY" != "true" ]]; then | |
| if [[ $(uname) != "Darwin" ]]; then | |
| echo "Warning: Installation is only supported on macOS. Skipping installation." | |
| else | |
| if install_vmware_fusion "$dmg_path" "$latest_version" "$latest_filename"; then | |
| echo | |
| echo "You can now launch VMware Fusion from /Applications/ or Spotlight." | |
| show_license_info | |
| else | |
| echo "Installation failed. The DMG file is available at: $dmg_path" | |
| exit 1 | |
| fi | |
| fi | |
| else | |
| echo "Opening Downloads folder..." | |
| [[ $(uname) == "Darwin" ]] && open "$DOWNLOAD_DIR" | |
| if [[ "$DOWNLOAD_ONLY" != "true" ]]; then | |
| echo | |
| echo "To install manually, double-click the DMG file and drag VMware Fusion to Applications." | |
| show_license_info | |
| fi | |
| fi | |
| } | |
| main "$@" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4A4RR-813DK-M81A9-4U35H-06KND
NZ4RR-FTK5H-H81C1-Q30QH-1V2LA
4C21U-2KK9Q-M8130-4V2QH-CF810
MC60H-DWHD5-H80U9-6V85M-8280D
JU090-6039P-08409-8J0QH-2YR7F
4Y09U-AJK97-089Z0-A3054-83KLA