-
Notifications
You must be signed in to change notification settings - Fork 5
/
admin.sh
57 lines (42 loc) · 1.06 KB
/
admin.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# BASE_URL="https://bambi11.enoflag.de"
if [ -z "${BASE_URL}" ]; then
echo "BASE_URL is not set!"
fi
CHECKIN_API_URL="${BASE_URL}/api/admin/checkinteam"
BOOT_API_URL="${BASE_URL}/api/admin/bootvm"
IPS_API_URL="${BASE_URL}/api/data/ips"
if [ -z "${ADMIN_SECRET}" ]; then
echo "ADMIN_SECRET is not set!"
fi
CheckInTeam () {
if [[ "$#" -lt 1 ]]; then
echo "CheckInTeam TEAM_ID";
return -1;
fi
TEAM_ID="$1"
curl --get "$CHECKIN_API_URL" \
--data-urlencode "adminSecret=${ADMIN_SECRET}" \
--data-urlencode "id=${TEAM_ID}"
}
BootVM () {
if [[ "$#" -lt 1 ]]; then
echo "BootVM TEAM_ID";
return -1;
fi
TEAM_ID="$1"
curl --get "$BOOT_API_URL" \
--data-urlencode "adminSecret=${ADMIN_SECRET}" \
--data-urlencode "teamId=${TEAM_ID}"
}
BootAllCheckins () {
# while true; do
IP_LIST="$(curl "$IPS_API_URL")"
echo "$IP_LIST"
for ip in $IP_LIST; do
TEAM_ID=`echo $ip | cut -d. -f 3`
echo "ID $TEAM_ID ($ip)"
BootVM "$TEAM_ID"
sleep 2;
done
}