-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup-nodes.sh
executable file
·63 lines (57 loc) · 1.8 KB
/
setup-nodes.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
57
58
59
60
61
62
63
#!/bin/bash
NETWORK="swan"
NODES=( \
"51da.uk" \
"51db.uk" \
"51dc.uk" \
"51dd.uk" \
"51de.uk" \
)
STARTDATE=$(date -u +"%Y-%m-%dT%H:%M")
EXPIRYDATE=$(date -u -d '+90 days' '+%Y-%m-%d')
echo "Network: ${NETWORK}"
echo "Starts: ${STARTDATE}"
echo "Expiry: ${EXPIRYDATE}"
read -r -p "Ok? [y/N] " response
if ! [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
exit 0
fi
## Set-up SWIFT access nodes as OWID creators
for n in ${NODES[*]}; do
echo "51Degrees : ${n}"
URL="http://${n}/owid/register?name=51Degrees"
echo $URL
RES=$(curl --write-out '%{http_code}' --silent --output /dev/null ${URL})
echo $RES
done
## Set-up SWAN participant as OWID creators
DIR=$(find www -maxdepth 1 -mindepth 1 -type d)
for d in $DIR; do
if [ -e "${d}/config.json" ]; then
NAME=$(jq --raw-output "if .Name != null then .Name else .name end" "${d}/config.json" | tr " " +)
DOMAIN=$(basename ${d})
echo "${NAME} : ${DOMAIN}"
URL="http://${DOMAIN}/owid/register?name=${NAME}"
echo $URL
RES=$(curl --write-out '%{http_code}' --silent --output /dev/null ${URL})
echo $RES
fi
done
## Set-up SWIFT access nodes
for n in ${NODES[*]}; do
echo "51Degrees : ${n}"
URL="http://${n}/swift/register?network=${NETWORK}&starts=${STARTDATE}&expires=${EXPIRYDATE}&role=0"
echo $URL
RES=$(curl --write-out '%{http_code}' --silent --output /dev/null ${URL})
echo $RES
done
# ## Set-up SWIFT storage Nodes
for n in ${NODES[*]}; do
for i in `seq 1 30`; do
echo "51Degrees : ${i}.${n}"
URL="http://${i}.${n}/swift/register?network=${NETWORK}&starts=${STARTDATE}&expires=${EXPIRYDATE}&role=1"
echo $URL
RES=$(curl --write-out '%{http_code}' --silent --output /dev/null ${URL})
echo $RES
done
done