@@ -393,6 +393,245 @@ install_package() {
393393 print_success " Package installed successfully"
394394}
395395
396+ # Function to check if macFUSE is installed
397+ check_macfuse_installed () {
398+ if [ -d " /Library/Frameworks/macFUSE.framework" ] || [ -d " /Library/Frameworks/OSXFUSE.framework" ]; then
399+ return 0 # Already installed
400+ fi
401+ return 1 # Not installed
402+ }
403+
404+ # Function to get latest macFUSE version
405+ get_macfuse_latest_version () {
406+ local api_url=" https://api.github.com/repos/osxfuse/osxfuse/releases/latest"
407+ local temp_file
408+ temp_file=$( mktemp)
409+
410+ if download_file " $api_url " " $temp_file " ; then
411+ local version
412+ version=$( jq -r ' .tag_name' " $temp_file " 2> /dev/null)
413+ rm -f " $temp_file "
414+ echo " $version "
415+ else
416+ rm -f " $temp_file "
417+ # Fallback to a known stable version
418+ echo " macfuse-4.4.3"
419+ fi
420+ }
421+
422+ # Function to install macFUSE
423+ install_macfuse () {
424+ print_info " Installing macFUSE (required dependency)..."
425+
426+ # Check if already installed
427+ if check_macfuse_installed; then
428+ print_success " macFUSE is already installed"
429+ return 0
430+ fi
431+
432+ local temp_dir
433+ temp_dir=$( mktemp -d)
434+
435+ # Cleanup function for macFUSE installation
436+ cleanup_macfuse () {
437+ rm -rf " $temp_dir "
438+ }
439+ trap cleanup_macfuse EXIT
440+
441+ # Get latest version
442+ local version
443+ version=$( get_macfuse_latest_version)
444+ print_info " Installing macFUSE version: $version "
445+
446+ # Download macFUSE
447+ local macfuse_url=" https://github.com/osxfuse/osxfuse/releases/download/$version /$version .dmg"
448+ local dmg_file=" $temp_dir /macfuse.dmg"
449+
450+ print_info " Downloading macFUSE..."
451+ if ! download_file " $macfuse_url " " $dmg_file " ; then
452+ print_error " Failed to download macFUSE"
453+ return 1
454+ fi
455+
456+ # Mount the DMG
457+ print_info " Mounting macFUSE installer..."
458+ local mount_point=" /Volumes/macFUSE"
459+ if ! hdiutil attach " $dmg_file " -quiet -mountpoint " $mount_point " ; then
460+ print_error " Failed to mount macFUSE DMG"
461+ return 1
462+ fi
463+
464+ # Find the installer package
465+ local pkg_file
466+ pkg_file=$( find " $mount_point " -name " *.pkg" | head -n1)
467+
468+ if [ -z " $pkg_file " ]; then
469+ print_error " macFUSE installer package not found"
470+ hdiutil detach " $mount_point " -quiet
471+ return 1
472+ fi
473+
474+ # Install the package
475+ print_info " Installing macFUSE package (requires admin password)..."
476+ if sudo installer -pkg " $pkg_file " -target /; then
477+ print_success " macFUSE installed successfully"
478+
479+ # Unmount the DMG
480+ hdiutil detach " $mount_point " -quiet
481+
482+ # Check if installation was successful
483+ if check_macfuse_installed; then
484+ print_success " macFUSE installation verified"
485+ return 0
486+ else
487+ print_warning " macFUSE installation may require a reboot to complete"
488+ return 0
489+ fi
490+ else
491+ print_error " Failed to install macFUSE package"
492+ hdiutil detach " $mount_point " -quiet
493+ return 1
494+ fi
495+ }
496+
497+ # Alternative: Install via Homebrew if available
498+ install_macfuse_via_homebrew () {
499+ if ! command_exists brew; then
500+ return 1 # Homebrew not available
501+ fi
502+
503+ print_info " Installing macFUSE via Homebrew..."
504+
505+ # Add the cask tap if not already added
506+ if ! brew tap | grep -q " homebrew/cask" ; then
507+ brew tap homebrew/cask
508+ fi
509+
510+ # Install macFUSE
511+ if brew install --cask macfuse; then
512+ print_success " macFUSE installed via Homebrew"
513+ return 0
514+ else
515+ print_warning " Failed to install macFUSE via Homebrew"
516+ return 1
517+ fi
518+ }
519+
520+ # Function to handle macFUSE installation with multiple methods
521+ ensure_macfuse_installed () {
522+ # Skip if not on macOS
523+ # if [ "$(detect_os)" != "darwin" ]; then
524+ # return 0
525+ # fi
526+
527+ # Check if already installed
528+ if check_macfuse_installed; then
529+ print_info " macFUSE is already installed"
530+ return 0
531+ fi
532+
533+ print_info " macFUSE is required for TigrisFS on macOS"
534+
535+ # Ask user for installation preference
536+ if [ -z " $SKIP_MACFUSE " ]; then
537+ echo -n " Install macFUSE now? [Y/n]: "
538+ read -r install_choice
539+
540+ case " ${install_choice,,} " in
541+ n|no)
542+ print_warning " Skipping macFUSE installation"
543+ print_info " Note: TigrisFS may not work without macFUSE"
544+ return 0
545+ ;;
546+ esac
547+ fi
548+
549+ # Try Homebrew first if available (cleaner installation)
550+ if install_macfuse_via_homebrew; then
551+ return 0
552+ fi
553+
554+ # Fall back to direct installation
555+ print_info " Homebrew not available or failed, using direct installation..."
556+ if install_macfuse; then
557+ return 0
558+ fi
559+
560+ print_error " Failed to install macFUSE"
561+ print_info " Please install macFUSE manually from: https://osxfuse.github.io/"
562+
563+ # Ask if user wants to continue without macFUSE
564+ echo -n " Continue TigrisFS installation anyway? [y/N]: "
565+ read -r continue_choice
566+
567+ case " ${continue_choice,,} " in
568+ y|yes)
569+ print_warning " Continuing without macFUSE - TigrisFS may not function properly"
570+ return 0
571+ ;;
572+ * )
573+ print_info " Installation aborted"
574+ exit 1
575+ ;;
576+ esac
577+ }
578+
579+ # Function to check macOS version compatibility
580+ check_macos_compatibility () {
581+ local macos_version
582+ macos_version=$( sw_vers -productVersion)
583+ local major_version
584+ major_version=$( echo " $macos_version " | cut -d. -f1)
585+
586+ # macFUSE requires macOS 10.9 or later
587+ if [ " $major_version " -lt 10 ]; then
588+ print_error " macOS version $macos_version is too old for macFUSE"
589+ return 1
590+ fi
591+
592+ # Check for specific version requirements
593+ case " $major_version " in
594+ 10)
595+ local minor_version
596+ minor_version=$( echo " $macos_version " | cut -d. -f2)
597+ if [ " $minor_version " -lt 9 ]; then
598+ print_error " macOS 10.9 or later is required for macFUSE"
599+ return 1
600+ fi
601+ ;;
602+ esac
603+
604+ return 0
605+ }
606+
607+ # Integration into main installation flow
608+ install_macos_dependencies () {
609+ if [ " $( detect_os) " != " darwin" ]; then
610+ return 0 # Not macOS, skip
611+ fi
612+
613+ print_info " Checking macOS dependencies..."
614+
615+ # Check macOS compatibility
616+ if ! check_macos_compatibility; then
617+ exit 1
618+ fi
619+
620+ # Install macFUSE
621+ ensure_macfuse_installed
622+
623+ # Check for other macOS-specific requirements
624+ if ! command_exists pkgutil; then
625+ print_warning " pkgutil not found - some features may not work"
626+ fi
627+
628+ # Inform about security settings
629+ if check_macfuse_installed; then
630+ print_info " Note: You may need to allow macFUSE in System Preferences > Security & Privacy"
631+ print_info " after the first run if prompted by macOS"
632+ fi
633+ }
634+
396635# Main installation function
397636main () {
398637 print_info " TigrisFS Installation Script"
@@ -409,6 +648,8 @@ main() {
409648
410649 # Check dependencies
411650 check_dependencies " $package_type "
651+ # Install macOS dependencies (including macFUSE)
652+ install_macos_dependencies
412653
413654 # Get latest release info
414655 local release_file
@@ -541,7 +782,7 @@ main() {
541782 # Show version if possible
542783 if " $BINARY_NAME " --version > /dev/null 2>&1 ; then
543784 local version
544- version=$( " $BINARY_NAME " --version 2>&1 | head -n1 | cut -d ' ' -f 3)
785+ version=$( " $BINARY_NAME " --version 2>&1 | head -n1 | cut -d ' ' -f 3)
545786 print_info " Installed version: $version "
546787 fi
547788 else
@@ -625,6 +866,10 @@ while [[ $# -gt 0 ]]; do
625866 esac
626867 shift 2
627868 ;;
869+ --skip-macfuse)
870+ SKIP_MACFUSE=1
871+ shift
872+ ;;
628873 * )
629874 print_error " Unknown option: $1 "
630875 show_help
0 commit comments