- Add headscale binary and configuration files - Include management scripts for API keys, nodes, and authentication - Add Docker setup with docker-compose - Include backup and restore functionality - Add example scripts for creating API keys and pre-auth keys Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
28 lines
890 B
Bash
Executable File
28 lines
890 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# 定義變數以便於管理
|
|
API_URL="http://localhost:8080/api/v1/user"
|
|
AUTH_TOKEN="Bearer -YSEvxm.BAy6LySE1-WXm4MbsYoBxlI-5NpCPp70"
|
|
|
|
# 使用 curl 發送 HTTP 請求,帶有授權標頭
|
|
# -s: 靜默模式,不顯示進度條
|
|
# -f: 如果伺服器返回錯誤狀態碼,則失敗並返回非零狀態
|
|
# -o /dev/null: 將輸出丟棄(如果不需要顯示響應內容)
|
|
# -w: 輸出 HTTP 狀態碼以便檢查
|
|
response_status=$(curl -s -f -X GET \
|
|
-H "Authorization: $AUTH_TOKEN" \
|
|
"$API_URL" \
|
|
-w "%{http_code}" \
|
|
-o /dev/null)
|
|
|
|
# 檢查請求是否成功
|
|
if [ "$response_status" -eq 200 ]; then
|
|
echo "Request successful (Status: $response_status)"
|
|
# 如果需要顯示響應內容,可以移除 -o /dev/null 並直接輸出
|
|
# curl -s -X GET -H "Authorization: $AUTH_TOKEN" "$API_URL"
|
|
else
|
|
echo "Request failed (Status: $response_status)"
|
|
exit 1
|
|
fi
|
|
|