Files
headscale/api_user_request.sh
Timmy 1410ba6630 Initial commit: Headscale management scripts and configuration
- 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>
2026-03-24 10:08:28 +08:00

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