-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopCDN
executable file
·59 lines (52 loc) · 1.15 KB
/
stopCDN
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
57
58
#!/bin/bash
DNS_SERVER="cdn-dns.5700.network"
HTTP_HOSTS=(
"cdn-http1.5700.network"
"cdn-http2.5700.network"
"cdn-http3.5700.network"
"cdn-http4.5700.network"
"cdn-http5.5700.network"
"cdn-http6.5700.network"
"cdn-http7.5700.network"
)
DNS_DIR="dns_server"
HTTP_DIR="http_server"
# (1) PARSE INPUT ARGUMEMTS:
while getopts ":p:o:n:u:i:" args; do
case $args in
p)
port="$OPTARG"
;;
o)
origin="$OPTARG"
;;
n)
name="$OPTARG"
;;
u)
username="$OPTARG"
;;
i)
keyfile="$OPTARG"
;;
?)
echo "Invalid option -$OPTARG" >$2 # >$2=strerr
echo "Should be of form: ./stopCDN -p <port> -o <origin> -n <name> -u <username> -i <keyfile>" >$2
exit 1
;;
esac
done
# (2) SHUT DOWN DNS SERVER AND CLEAN:
ssh -i $keyfile $username@$DNS_SERVER "\
killall -u $username python3; \
rm -rf ~/$DNS_DIR/* \
"
# (3) SHUT DOWN HTTP SERVERS AND CLEAN:
for host in "${HTTP_HOSTS[@]}"; do
ssh -i $keyfile $username@$host "\
killall -u $username python3; \
rm -rf ~/$HTTP_DIR/* \
"
done
wait
echo "CDN successfully stopped and cleaned up."