feat: support macOS
This commit is contained in:
@ -87,7 +87,13 @@ class CoreManager:
|
||||
# Setup directories
|
||||
binary_dir = self.core_config_manager.storage.config_dir / "bin"
|
||||
binary_dir.mkdir(parents=True, exist_ok=True)
|
||||
binary_path = binary_dir / ("mihomo.exe" if system == "windows" else "mihomo")
|
||||
|
||||
# Add OS and arch as suffix to the binary name
|
||||
suffix = f"-{system}-{normalized_arch}"
|
||||
if system == "windows":
|
||||
binary_path = binary_dir / f"mihomo{suffix}.exe"
|
||||
else:
|
||||
binary_path = binary_dir / f"mihomo{suffix}"
|
||||
|
||||
# Check if binary already exists
|
||||
if binary_path.exists() and not force:
|
||||
@ -227,8 +233,27 @@ class CoreManager:
|
||||
def get_binary_path(self) -> Path:
|
||||
"""Get the path to the mihomo executable."""
|
||||
system = platform.system().lower()
|
||||
machine = platform.machine().lower()
|
||||
|
||||
# Normalize architecture names
|
||||
arch_map = {
|
||||
'x86_64': 'amd64',
|
||||
'amd64': 'amd64',
|
||||
'i386': '386',
|
||||
'i686': '386',
|
||||
'arm64': 'arm64',
|
||||
'aarch64': 'arm64',
|
||||
'armv7l': 'arm',
|
||||
'arm': 'arm'
|
||||
}
|
||||
normalized_arch = arch_map.get(machine, machine)
|
||||
|
||||
binary_dir = self.core_config_manager.storage.config_dir / "bin"
|
||||
binary_path = binary_dir / ("mihomo.exe" if system == "windows" else "mihomo")
|
||||
suffix = f"-{system}-{normalized_arch}"
|
||||
if system == "windows":
|
||||
binary_path = binary_dir / f"mihomo{suffix}.exe"
|
||||
else:
|
||||
binary_path = binary_dir / f"mihomo{suffix}"
|
||||
return binary_path
|
||||
|
||||
def install_service(self, service_name: str = "mihomo", description: str = "Mihomo proxy service") -> bool:
|
||||
@ -259,7 +284,7 @@ class CoreManager:
|
||||
print(f"✅ Generated initial configuration: {config_file}")
|
||||
|
||||
# Build service arguments
|
||||
service_args = f"-d \"{config_dir}\" -f \"{config_file}\""
|
||||
service_args = f"-d {config_dir} -f {config_file}"
|
||||
|
||||
service_manager = ServiceManager(self.storage.config_dir)
|
||||
service_manager.install(service_name, str(binary_path), description, service_args)
|
||||
|
||||
Reference in New Issue
Block a user