#!/bin/bash # 设置脚本遇到错误时退出 set -e # 定义颜色 RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color # 检查是否为 macOS if [[ "$(uname)" != "Darwin" ]]; then echo -e "${RED}This script is intended for macOS only.${NC}" exit 1 fi # 检查是否已安装 Homebrew if ! command -v brew &> /dev/null; then echo -e "${YELLOW}Homebrew is not installed. Installing...${NC}" /bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" if [ $? -ne 0 ]; then echo -e "${RED}Failed to install Homebrew. Please install it manually and then rerun this script.${NC}" exit 1 fi echo -e "${GREEN}Homebrew installed successfully!${NC}" else # 更新 Homebrew echo -e "${YELLOW}Updating Homebrew...${NC}" brew update if [ $? -ne 0 ]; then echo -e "${RED}Warning: Failed to update Homebrew. Continuing anyway...${NC}" fi fi # 安装 FFmpeg if ! brew list --versions ffmpeg &> /dev/null; then echo -e "${YELLOW}Installing FFmpeg...${NC}" brew install ffmpeg if [ $? -ne 0 ]; then echo -e "${RED}Failed to install FFmpeg.${NC}" exit 1 fi echo -e "${GREEN}FFmpeg installed successfully!${NC}" else echo -e "${YELLOW}FFmpeg is already installed. Skipping...${NC}" fi # 安装 macFUSE, ntfs-3g-mac 和 Mounty (用于 NTFS 写入支持) # see https://mounty.app/#installation # macFUSE (Cask) if ! brew list --cask --versions macfuse &> /dev/null; then echo -e "${YELLOW}Installing macFUSE...${NC}" brew install --cask macfuse if [ $? -ne 0 ]; then echo -e "${RED}Failed to install macFUSE. You may need to install it manually from https://osxfuse.github.io/. Continuing...${NC}" fi else echo -e "${YELLOW}macFUSE is already installed. Skipping...${NC}" fi # ntfs-3g-mac (Formula) if ! brew list --versions ntfs-3g-mac &> /dev/null; then echo -e "${YELLOW}Installing ntfs-3g-mac...${NC}" brew install gromgit/fuse/ntfs-3g-mac if [ $? -ne 0 ]; then echo -e "${RED}Failed to install ntfs-3g-mac. This may cause issues with writing to NTFS drives. Continuing...${NC}" fi else echo -e "${YELLOW}ntfs-3g-mac is already installed. Skipping...${NC}" fi # Mounty (Cask) if ! brew list --cask --versions mounty &> /dev/null; then echo -e "${YELLOW}Installing Mounty...${NC}" brew install --cask mounty if [ $? -ne 0 ]; then echo -e "${RED}Failed to install Mounty. You may need to manually mount NTFS drives. Continuing...${NC}" fi else echo -e "${YELLOW}Mounty is already installed. Skipping...${NC}" fi
echo -e "${GREEN}Installation complete!${NC}" echo -e "${YELLOW}Please reboot your computer for the changes (especially macFUSE) to take effect.${NC}" echo -e "${YELLOW}After rebooting, you may need to manually enable 'System Extensions' for macFUSE in System Preferences > Security & Privacy > General.${NC}" echo -e "${GREEN}If you encounter any issues, run 'brew doctor' to diagnose potential problems.${NC}"