forked from shawwn/scrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudflare-tpu-update
executable file
·48 lines (36 loc) · 989 Bytes
/
cloudflare-tpu-update
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/sh
id="${1}"
shift 1
if [ -z "${id}" ]
then
1>&2 echo "usage:"
1>&2 echo " ${0} <id> [<option>]"
exit 1
fi
set -e
js="$(pu list -t "$id" --format json)"
jstxt="$(printf "%s" "$js" | gzip | b64enc)"
cat <<EOF
cloudflare-dns --verbose -d "t${id}.*gpt4.org"
cloudflare-dns --verbose "t${id}.gpt4.org" -k TXT -f <(printf "%s" "$jstxt")
EOF
printf "%s" "$js" | jq '.networkEndpoints[].accessConfig.externalIp' -r | python3 -c 'import sys;
for i, ip in enumerate(sys.stdin):
ip = ip.strip()
if ip == "null":
#ip = "-d"
continue
else:
ip = "-u " + ip
print("cloudflare-dns --verbose t%s.%d.gpt4.org %s" % (sys.argv[1], i, ip))
' "$id"
printf "%s" "$js" | jq '.networkEndpoints[].ipAddress' -r | python3 -c 'import sys;
for i, ip in enumerate(sys.stdin):
ip = ip.strip()
if ip == "null":
#ip = "-d"
continue
else:
ip = "-u " + ip
print("cloudflare-dns --verbose t%s.%d.ip.gpt4.org %s" % (sys.argv[1], i, ip.strip()))
' "$id"