-
Notifications
You must be signed in to change notification settings - Fork 1
/
runCDN
executable file
·37 lines (34 loc) · 1.1 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
#!/usr/bin/env bash
DNS_SERVER=proj4-dns.5700.network
DNS_DIR='dns_server'
HTTP_REPLICAS=(proj4-repl1.5700.network
proj4-repl2.5700.network
proj4-repl3.5700.network
proj4-repl4.5700.network
proj4-repl5.5700.network
proj4-repl6.5700.network
proj4-repl7.5700.network)
HTTP_DIR='http_server'
while getopts p:o:n:u:i: flag
do
case "${flag}" in
p) port=${OPTARG};;
o) origin=${OPTARG};;
n) name=${OPTARG};;
u) username=${OPTARG};;
i) keyfile=${OPTARG};;
esac
done
# run each CDN replica
echo "Setting up CDN replicas..."
for replica in "${HTTP_REPLICAS[@]}"
do
echo "Attempting to run replica: $username@$replica..."
ssh -i $keyfile $username@$replica "cd $HTTP_DIR; nohup ./httpserver -p $port -o $origin &>logs.txt" &
echo "Replica running at: $username@$replica"
done
echo "All replicas running!"
# run DNS server
echo "Attempting to run DNS Server..."
ssh -i $keyfile $username@$DNS_SERVER "cd $DNS_DIR; nohup ./dnsserver -p $port -n $name &>logs.txt" &
echo "DNS server is running!"