-
Notifications
You must be signed in to change notification settings - Fork 5
/
runCDN
executable file
·64 lines (52 loc) · 1.25 KB
/
runCDN
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
59
60
61
62
63
64
#!/bin/bash
OPTINDEX=1
# Initialize our own variables:
port=""
origin=""
name=""
user=""
identity=""
numhost=$(wc -l < ./ec2-hosts.txt)
while getopts "p:o:n:u:i:" opt; do
case "$opt" in
p) port=$OPTARG
;;
o) origin=$OPTARG
;;
n) name=$OPTARG
;;
u) user=$OPTARG
;;
i) identity=$OPTARG
;;
esac
done
shift $((OPTIND-1))
echo "Running runCDN against the following options:"
echo "port=$port, origin=$origin, name=$name, user=$user, identity=$identity, Not Parsed: $@"
echo ""
i=0
host=($(cut -d$'\t' -f1 ./ec2-hosts.txt))
for h in "${host[@]}"; do
echo ""
echo "Attempting to run httpserver on host ${h}"
echo ""
ssh -t -oStrictHostKeyChecking=no -i $identity $user@$h << ENDSSH &> /dev/null
cd /home/$user/CDN
nohup ./httpserver -p $port -o $origin > http.out 2> http.err < /dev/null &
ENDSSH
done
echo "Attempting to run dns server"
echo ""
ssh -t -oStrictHostKeyChecking=no -i $identity $user@cs5700cdnproject.ccs.neu.edu << ENDSSH &> /dev/null
cd /home/$user/CDN
./dnsserver -p $port -n $name > dns.out 2> dns.err &
ENDSSH
echo ""
echo "Precaching hompage on replicas"
echo ""
for h in "${host[@]}"; do
echo "Precaching against host ${h}"
curl http://$h:$port/ &> /dev/null
done
echo ""