-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathwarp-reg.sh
More file actions
43 lines (35 loc) · 1.31 KB
/
warp-reg.sh
File metadata and controls
43 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# 定义颜色代码
RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'
# 根据系统架构自动判定 warp-reg 下载链接
get_warp_reg() {
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
download_url="https://github.com/badafans/warp-reg/releases/download/v1.0/main-linux-amd64"
elif [[ "$arch" == "aarch64" ]]; then
download_url="https://github.com/badafans/warp-reg/releases/download/v1.0/main-linux-arm64"
elif [[ "$arch" == "armv7l" ]]; then
download_url="https://github.com/badafans/warp-reg/releases/download/v1.0/main-linux-arm"
else
echo -e "${RED}不支持的系统架构: $arch${RESET}"
exit 1
fi
# 下载并执行 warp-reg
output=$(curl -sLo warp-reg "$download_url" && chmod +x warp-reg && ./warp-reg && rm warp-reg)
# 使用 grep 提取需要的字段
WARP_private=$(echo "$output" | grep -oP '(?<=private_key: ).*')
WARP_IPV6=$(echo "$output" | grep -oP '(?<=v6: ).*')
WARP_Reserved=$(echo "$output" | grep -oP '(?<=reserved: \[ ).*(?= \])')
# 输出提取的信息
echo -e "${GREEN}WARP_Reserved: $WARP_Reserved${RESET}"
echo -e "${GREEN}WARP_IPV6: $WARP_IPV6${RESET}"
echo -e "${GREEN}WARP_private: $WARP_private${RESET}"
}
# 主程序
main() {
get_warp_reg
}
# 执行主程序
main