mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix: 5: Input/output error when install macos helper
This commit is contained in:
parent
6f3845151d
commit
151726fcce
@ -74,7 +74,9 @@ cat << EOF > "$LAUNCH_DAEMON"
|
|||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>party.mihomo.helper</string>
|
<string>party.mihomo.helper</string>
|
||||||
<key>AssociatedBundleIdentifiers</key>
|
<key>AssociatedBundleIdentifiers</key>
|
||||||
|
<array>
|
||||||
<string>party.mihomo.app</string>
|
<string>party.mihomo.app</string>
|
||||||
|
</array>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>Program</key>
|
<key>Program</key>
|
||||||
@ -91,18 +93,62 @@ chown root:wheel "$LAUNCH_DAEMON"
|
|||||||
chmod 644 "$LAUNCH_DAEMON"
|
chmod 644 "$LAUNCH_DAEMON"
|
||||||
log "LaunchDaemon configured"
|
log "LaunchDaemon configured"
|
||||||
|
|
||||||
# 加载并启动服务
|
# 验证关键文件
|
||||||
log "Loading and starting service..."
|
log "Verifying installation..."
|
||||||
launchctl unload "$LAUNCH_DAEMON" 2>/dev/null || true
|
if [ ! -x "$HELPER_PATH" ]; then
|
||||||
if ! launchctl load "$LAUNCH_DAEMON"; then
|
log "Error: Helper tool is not executable: $HELPER_PATH"
|
||||||
log "Error: Failed to load helper service"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! launchctl start party.mihomo.helper; then
|
# 检查二进制文件有效性
|
||||||
log "Error: Failed to start helper service"
|
if ! file "$HELPER_PATH" | grep -q "Mach-O"; then
|
||||||
|
log "Error: Helper tool is not a valid Mach-O binary"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 验证 plist 格式
|
||||||
|
if ! plutil -lint "$LAUNCH_DAEMON" >/dev/null 2>&1; then
|
||||||
|
log "Error: Invalid plist format"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 获取 macOS 版本
|
||||||
|
macos_version=$(sw_vers -productVersion)
|
||||||
|
macos_major=$(echo "$macos_version" | cut -d. -f1)
|
||||||
|
log "macOS version: $macos_version"
|
||||||
|
|
||||||
|
# 清理现有服务
|
||||||
|
log "Cleaning up existing services..."
|
||||||
|
launchctl bootout system "$LAUNCH_DAEMON" 2>/dev/null || true
|
||||||
|
launchctl unload "$LAUNCH_DAEMON" 2>/dev/null || true
|
||||||
|
|
||||||
|
# 加载服务
|
||||||
|
log "Loading service..."
|
||||||
|
if [ "$macos_major" -ge 11 ]; then
|
||||||
|
# macOS Big Sur 及更新版本使用 bootstrap
|
||||||
|
if ! launchctl bootstrap system "$LAUNCH_DAEMON"; then
|
||||||
|
log "Bootstrap failed, trying legacy load..."
|
||||||
|
if ! launchctl load "$LAUNCH_DAEMON"; then
|
||||||
|
log "Error: Failed to load service with both methods"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# 旧版本使用 load
|
||||||
|
if ! launchctl load "$LAUNCH_DAEMON"; then
|
||||||
|
log "Error: Failed to load service"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
log "Verifying service status..."
|
||||||
|
sleep 2
|
||||||
|
if launchctl list | grep -q "party.mihomo.helper"; then
|
||||||
|
log "Service loaded successfully"
|
||||||
|
else
|
||||||
|
log "Warning: Service may not be running properly"
|
||||||
|
fi
|
||||||
|
|
||||||
log "Installation completed successfully"
|
log "Installation completed successfully"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user