-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-network
executable file
·52 lines (41 loc) · 1.8 KB
/
run-network
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
#!/bin/bash
#
# Copyright 2010 Jeremy Schneider
#
# This file is part of EC2-RAC-BUILDER.
#
# EC2-RAC-BUILDER is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# EC2-RAC-BUILDER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EC2-RAC-BUILDER. If not, see <http://www.gnu.org/licenses/>.
#
#
[ -n "$DEBUG" ] && set -x
[ -z "$1" ] && { echo "Usage: run-network <cluster#>" && exit 1; }
[ $1 -gt 0 ] || { echo "ERROR: cluster# must be number greater than 0" && exit 1; }
echo "starting" >&2
. $(dirname $0)/env
echo 0 > /tmp/amazon/cluster$1-network
RUNOUT="$(ec2run -z $EC2_ZONE -t m1.small -k $EC2_KEY -n 2 -g default -g vpncubed-mgr ami-a89464c1)"
echo "$RUNOUT"
INST=($(echo "$RUNOUT"|awk '/^INSTANCE/{print$2}'))
# ${#INST[*]} is number of elements in array
ec2tag ${INST[0]} -t "Name=c$1-switch-pub" -t "Cluster=$1" -t "Function=public-network" -t "Netmask=172.17.17.0/24" &
ec2tag ${INST[1]} -t "Name=c$1-switch-priv" -t "Cluster=$1" -t "Function=private-network" -t "Netmask=192.168.17.0/24" &
$(dirname $0)/init-network-node ${INST[0]} public &
I_PIDS="$!"
$(dirname $0)/init-network-node ${INST[1]} private &
I_PIDS="$I_PIDS $!"
# $! is PID of most recently executed bg job
# ps h list_of_pids will give 1 line for each running process, empty when they all complete
until [ -z "$(ps h $I_PIDS)" ]; do sleep 5; done
echo 1 > /tmp/amazon/cluster$1-network
echo "finished" >&2