Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 49 lines (40 sloc) 1.883 kB
b316bc2 @ardentperf first commit
authored
1 #!/bin/bash
2 #
3 # Copyright 2010 Jeremy Schneider
4 #
5 # This file is part of EC2-RAC-BUILDER.
6 #
7 # EC2-RAC-BUILDER is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # EC2-RAC-BUILDER is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
15a0452 @ardentperf fix typo in license header
authored
18 # along with EC2-RAC-BUILDER. If not, see <http://www.gnu.org/licenses/>.
b316bc2 @ardentperf first commit
authored
19 #
20 #
21
22 [ -n "$DEBUG" ] && set -x
23
24 [ -z "$2" ] && { echo "Usage: init-network-node <instance-id> [ public | private ]" && exit 1; }
25 [ "$2" != "public" ] && [ "$2" != "private" ] && { echo "ERROR: unrecognized parameter '$2'" && exit 1; }
26
27 . $(dirname $0)/env
28
c4c255b @ardentperf instrumentation to stderr, validate NET_ID, save compute node IPs
authored
29 echo "ec2 load instance" >&2
b316bc2 @ardentperf first commit
authored
30 DOUT="$(ec2din $1)"
31 ADDR=$(echo "$DOUT"|awk '/running/{print$4}')
32 while [ -z "$ADDR" ]; do
33 [ -z "$(echo "$DOUT"|grep ^INSTANCE)" ] && echo "$DOUT" && echo "ERROR - can't find instance '$1'" && exit 1
34 DOUT="$(ec2din $1)"
35 ADDR=$(echo "$DOUT"|awk '/running/{print$4}')
36 done
37 echo "$DOUT"
38
9d454b4 @ardentperf cleanup instrumentation
authored
39 echo "boot O.S." >&2
40 until curl -u vpncubed:$1 -k https://$ADDR:8000/ 2>&1 | grep "Upload runtime snapshot"; do sleep 5; done
b316bc2 @ardentperf first commit
authored
41
c4c255b @ardentperf instrumentation to stderr, validate NET_ID, save compute node IPs
authored
42 echo "configure switch" >&2
9d454b4 @ardentperf cleanup instrumentation
authored
43 TOKEN=$(curl -u vpncubed:$1 -k -c /tmp/amazon/$1.cookie https://$ADDR:8000/snapshot 2>/dev/null | grep "authenticity_token"|sed 's/.*value="\(.*\)".*/\1/')
44 curl -u vpncubed:$1 -k -b /tmp/amazon/$1.cookie -F snapshot=@snapshot_$2.gz -F authenticity_token=$TOKEN https://$ADDR:8000/snapshot 2>&1
b316bc2 @ardentperf first commit
authored
45
9d454b4 @ardentperf cleanup instrumentation
authored
46 echo "reboot O.S." >&2
47 until curl -u vpncubed:rac -k https://$ADDR:8000/status 2>&1 | grep "RAC-$2"; do sleep 5; done
b316bc2 @ardentperf first commit
authored
48
Something went wrong with that request. Please try again.