Files
modelscope/scripts/delete-runner.sh
2026-02-02 03:56:12 +00:00

40 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 配置信息
GITEA_URL="https://gitea.tailnet-68f9.ts.net"
TOKEN="8d7d70f324796be650b79415303c31f567bf459b"
# runner ID 从命令行参数获取默认为5
RUNNER_ID=${1:-5}
# 函数删除指定ID的runner
function delete_runner() {
local runner_id=$1
echo "尝试删除runner #$runner_id..."
response=$(curl -s -w "\n%{http_code}" -X DELETE \
-H "Authorization: token $TOKEN" \
"$GITEA_URL/api/v1/actions/runners/$runner_id")
# 分离响应内容和HTTP状态码
http_status=$(echo "$response" | tail -n1)
response_body=$(echo "$response" | sed '$d')
if [ "$http_status" -eq 204 ] || [ "$http_status" -eq 200 ]; then
echo "成功删除runner #$runner_id"
echo "响应: $response_body"
else
echo "删除runner #$runner_id 失败"
echo "HTTP状态码: $http_status"
echo "响应: $response_body"
fi
}
# 主脚本
echo "=== 删除Gitea Runner ==="
echo ""
# 直接删除runner
echo "将要删除runner ID: $RUNNER_ID"
delete_runner $RUNNER_ID