#!/bin/bash

# macOS launchd服務配置腳本

PLIST_FILE=/Users/accusys/markbase/scripts/com.gitea.runner.plist
LAUNCH_AGENTS=~/Library/LaunchAgents

echo "配置 Gitea Runner為 macOS系統服務..."

#複製plist到LaunchAgents
cp "$PLIST_FILE" "$LAUNCH_AGENTS/com.gitea.runner.plist"

#載入服務
launchctl load "$LAUNCH_AGENTS/com.gitea.runner.plist"

#驗證服務狀態
echo "驗證服務狀態..."
launchctl list | grep gitea

echo ""
echo "Runner服務已配置！"
echo ""
echo "管理命令："
echo "  啟動：launchctl load ~/Library/LaunchAgents/com.gitea.runner.plist"
echo "  停止：launchctl unload ~/Library/LaunchAgents/com.gitea.runner.plist"
echo "  狀態：launchctl list | grep gitea"
echo "  日誌：tail -f /tmp/gitea-runner.log"
echo ""