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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#!/bin/sh -x
# This script lives in the lut provider and should be run from there
provider_dir=`pwd`
platform_git=https://leap.se/git/leap_platform
cli_git=https://leap.se/git/leap_cli
from_version=$1
to_version=$2
#workdir=`mktemp -d`
workdir='/tmp/lut'
platform_link="${workdir}/leap_platform"
platform_from=${workdir}/platform_$1
platform_to=${workdir}/platform_$1
cli_from=${workdir}/cli_master
cli_to=${workdir}/cli_develop
# If you hit control-c or kill the process, stop the VMs
killed () {
leap vm stop upgrade
echo "VMs stopped, but not removed. Will still incur charges, please remove them if you are not using them anymore."
cleanup 3
}
trap "{ killed ; }" TERM INT ABRT QUIT
help () {
cat <<EOF
Usage lut <from version> <to version>
This script will setup leap platform, leap cli, for the versions required and
perform an upgrade test using leap vm credentials stored in cloud.json.
Note: the cloud.json file is encrypted with git-crypt. You need to decrypt it
first, just do once: apt install git-crypt and then git-crypt unlock.
EOF
}
check_version () {
git ls-remote --refs --heads --tags --exit-code $1 $2
if [ $? -ne 0 ]; then
echo "unknown <version>: $2 for $1, please use a tag from git tag -l, or specify a branch"
cleanup 2
fi
}
get_platform () {
echo "Setup platform, version $2"
git clone $1 ${workdir}/platform_${2} --branch $2
if [ $? -ne 0 ]; then
echo "Setup failed"
cleanup 2
fi
}
get_cli () {
cli_dir=${workdir}/cli_$2
echo "Setup leap_cli"
git clone $cli_git $cli_dir --branch $2
cd $cli_dir
rake build
bundle --path vendor/bundle
}
switch () {
rm -f $platform_link
ln -s platform_${1} $platform_link
}
cleanup () {
# leap vm stop upgrade
rm -rf $workdir
exit $1
}
start_nodes () {
echo "Starting all the VMs, you should go do something else now, this will take a while..."
# monarch: monitor, tor hidden service, webapp
leap vm add monarch
# dogface: couchdb/soledad
leap vm add dogface
# hairstreak: mx
leap vm add hairstreak
# checkerspot: openvn, need a gateway address to do openvpn, disabled
# spicebush: static node, with hidden service
leap vm add spicebush
# cloak: tor exit
leap vm add cloak
}
case "$1" in
-h | -help | --help )
help
exit
;;
esac
if [ $# -ne 2 ]; then
help
else
check_version $platform_git $from_version
check_version $platform_git $to_version
get_platform $platform_git $from_version
get_platform $platform_git $to_version
get_cli $cli_git master
get_cli $cli_git develop
cd $provider_dir
switch $to_version
start_nodes
# because 0.8 doesn't have the right support, we need
# to use the new version to do the node init
# switch $from_version
# $cli_from/bin/leap -v2 node init upgrade
$cli_to/bin/leap -v2 node init upgrade
if [ $? -ne 0 ]; then
cleanup 1
else
echo "Nodes initialized with old platform"
fi
# 0.8 hack, remove after 0.9 release
switch $from_version
$cli_from/bin/leap -v2 --yes deploy upgrade
if [ $? -ne 0 ]; then
cleanup 1
else
echo "Nodes deployed with old version of platform"
fi
$cli_from/bin/leap test
switch $to_version
$cli_to/bin/leap -v2 --yes deploy upgrade
if [ $? -ne 0 ]; then
cleanup 1
else
echo "Nodes deployed with new version of platform"
fi
$cli_to/bin/leap test
cleanup 0
fi
|