docs: 添加 macOS launchd 服务配置和安装指南 (#142)

This commit is contained in:
varz1
2025-09-24 11:49:04 +08:00
committed by GitHub
parent 177a64822d
commit c54c00b27c
3 changed files with 133 additions and 0 deletions

43
deploy/macos/xhsmcp.fish Normal file
View File

@@ -0,0 +1,43 @@
function xhsmcp_stop
launchctl stop xhsmcp
end
function xhsmcp_start
launchctl start xhsmcp
end
function xhsmcp_status
gomcp
set service_name "xhsmcp"
# 获取服务状态
set pid_status (launchctl list | grep $service_name | awk '{print $1}')
if test "$pid_status" != "-"
echo "$service_name 正在运行 (PID: $pid_status)"
read -P "是否停止服务? (yes/其他): " answer
if test "$answer" = "yes"
xhsmcp_stop
echo "✓ 服务已停止"
else
echo "取消操作"
end
else
echo "$service_name 未运行"
read -P "是否启动服务? (yes/其他): " answer
if test "$answer" = "yes"
xhsmcp_start
sleep 1
set pid_status (launchctl list | grep $service_name | awk '{print $1}')
if test "$pid_status" != "-"
echo "✓ 服务启动成功 (PID: $pid_status)"
else
echo "✗ 服务启动失败,检查日志: /tmp/xhsmcp.err"
return 1
end
else
echo "取消操作"
return 1
end
end
end