-
Notifications
You must be signed in to change notification settings - Fork 36
/
getBinariesFromBox.sh
executable file
·235 lines (161 loc) · 6.15 KB
/
getBinariesFromBox.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
BASEDIR=$(dirname $0)
source "$BASEDIR/utils.sh"
cd $BASEDIR
#
# These are the variables that need to be set
#
#BOX_PASSWORD=XXXXXX
if [ -z $BOX_USER ]
then
echo The following variables have to be set:
echo BOX_USER
echo BOX_PASSWORD
echo "Optionally, override BOX_URL (set to ftp.box.com/CI)"
exit 1
fi
#VERSIONS=()
SOFTWARE_DIR=software
LICENSES_DIR=licenses
# Create the dirs if they don't exist
if ! [ -d $SOFTWARE_DIR ]; then
mkdir $SOFTWARE_DIR
fi
if ! [ -d $LICENSES_DIR ]; then
mkdir $LICENSES_DIR
fi
VERSIONS=(6.1-QAT 7.0-QAT)
BOX_URL=${BOX_URL:-ftp.box.com/CI}
SOFTWARE_PATH=ee
VARIANT=ee
echo
echo Software download utility.
echo Connects to box with user \'$BOX_USER\' and downloads stuff
echo
# Get
OPTIONS=("Nightly Builds" "Stable releases")
promptUser "Which Release do you want to download? " "0"
b=${OPTIONS[$CHOICE]}
if [ $CHOICE -eq 0 ]; then
# Nightly builds. Get the list of them
echo Connecting to box to get the latest nightly builds...
result=$(lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL ;cls -1 * | grep -e '^[0-9].*' | grep -v \"Releases\" | grep -v \"NIGHTLY\" | grep -v \"SNAPSHOT\"" );
OPTIONS=();
for versionDir in $result
do
OPTIONS=("${OPTIONS[@]}" $(echo $versionDir | cut -d/ -f1) )
done;
promptUser "Nightly versions found " $(( ${#OPTIONS[@]} - 1 )) "Choose a version"
version=${OPTIONS[$CHOICE]}
# Logic to get the server prefix; 4.x, 5.x and 6.x use biserver-*, 7.x plus uses
# pentaho-server-*
if [[ $version =~ ^[456] ]]; then
serverPrefix="biserver"
else
serverPrefix="pentaho-server"
fi
# Getting the latest build number
result=$(lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL ; cls -1 --sort date $version | head -n 1");
BUILD=$(echo $result | cut -f2 -d/)
# Ask for buildno
read -e -p "Latest build is $BUILD. Which one do you want to download? [$BUILD]: " buildno
buildno=${buildno:-$BUILD}
# Ask for product; This will depend on the version
read -e -p "Which server ('ee' or 'ce')? [$VARIANT]: " variant
variant=${variant:-$VARIANT}
DOWNLOAD_DIR=$SOFTWARE_DIR/$version-$buildno
mkdir -p $DOWNLOAD_DIR
if [[ $variant =~ ce ]]; then
echo Downloading $version-$buildno $variant...
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version/$buildno/ce; mget -O $DOWNLOAD_DIR server/$serverPrefix-$variant-*-$buildno.zip";
else
# EE - download the bundles (ba and plugins)
echo Downloading $version-$buildno $variant and plugins...
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version/$buildno/ee; mget -O $DOWNLOAD_DIR server/$serverPrefix-$variant-*-$buildno-dist.zip ; \
mget -O $DOWNLOAD_DIR \
plugins/pir-plugin-ee-*-dist.zip \
plugins/paz-plugin-ee-*-dist.zip \
plugins/pdd-plugin-ee-*-dist.zip"
fi
elif [ "$CHOICE" -eq 1 ]
then
echo Connecting to box to get the latest stable versions...
result=$(lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL ; cls -1 --sort=name [5-9]*Releases ");
OPTIONS=();
for versionDir in $result
do
OPTIONS=("${OPTIONS[@]}" $(echo $versionDir | cut -d- -f1) )
done;
promptUser "Stable versions found " $(( ${#OPTIONS[@]} - 1 )) "Choose a version"
version=${OPTIONS[$CHOICE]}
# Logic to get the server prefix; 4.x, 5.x and 6.x use biserver-*, 7.x plus uses
# pentaho-server-*
if [[ $version =~ ^[456] ]]; then
serverPrefix="biserver"
else
serverPrefix="pentaho-server"
fi
# Now for the minor vesions
echo Connecting to box to get the latest dot versions for $version...
subVersions=$(lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version-Releases/ ; cls -1 --sort=name '[0-9S]*' " | grep -v '\-C');
minorVersions=$(echo "$subVersions" | egrep -o '^[0-9]+\.[0-9]+\.[0-9]+' | sort -u )
echo "Minor versions found: $minorVersions"
read -a OPTIONS <<< $minorVersions
echo Options size: ${#OPTIONS[@]}
promptUser "Minor versions found for $version " $(( ${#OPTIONS[@]} - 1 )) "Choose a version"
minorVersion=${OPTIONS[$CHOICE]}
echo Minor version: $minorVersion
DOWNLOAD_DIR=$SOFTWARE_DIR/$minorVersion
mkdir -p $DOWNLOAD_DIR
OPTIONS=("ee" "ce")
promptUser "You want EE or CE?" "0"
variant=${OPTIONS[$CHOICE]}
# Caveat - In 6.1 (at least?) the stable version is actually 6.1.0.1, and not
# 6.1.1.0.... Yay for coherency...
# Actually... the same also happens for 5.4.0.1...
dotDotVersion=0;
if [ "$minorVersion" == "6.1.0" ]; then
dotDotVersion=1;
fi
if [ "$minorVersion" == "5.4.0" ]; then
dotDotVersion=1;
fi
echo Sable release is $minorVersion.$dotDotVersion
if [[ $variant =~ ce ]]; then
# CE is actually easier; We'll download from $version-Releases/$version-.$minorVersion.0/ce/baserver
echo Downloading $minorVersion CE...
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version-Releases/$minorVersion.$dotDotVersion/ce; mget -O $DOWNLOAD_DIR $serverPrefix-$variant-*zip server/$serverPrefix-$variant-*zip"; 2>/dev/null
else
# EE - download the bundles (ba and plugin), and then the patches
echo " Downloading $minorVersion EE and plugins..."
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version-Releases/$minorVersion.$dotDotVersion/ee; mget -O $DOWNLOAD_DIR server/$serverPrefix-[^m]*zip ; \
mget -O $DOWNLOAD_DIR \
plugins/pir-plugin-ee-*-dist.zip \
plugins/paz-plugin-ee-*-dist.zip \
plugins/pdd-plugin-ee-*-dist.zip"
## Find dot versions that are relevant
for subV in $subVersions
do
# echo subversion: $subV
if [[ $subV =~ $minorVersion\.[^0][0-9.-]*/$ ]]; then
echo " Downloading $subV patches..."
# There are 2 possible formats - right on the dir and on a patches subdir
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version-Releases/$subV/; mget -O $DOWNLOAD_DIR SP*zip patch/SP*zip" 2>/dev/null
fi
done
# Older releases have the patches on the top level dir
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/$version-Releases/; mget -O $DOWNLOAD_DIR SP*zip patch/SP*zip" 2>/dev/null
fi
# If EE... also get licenses
if [[ $variant =~ ee ]]; then
rm $LICENSES_DIR/*lic
lftp -c "open -u $BOX_USER,$BOX_PASSWORD $BOX_URL/DEV_LICENSES/; mget -O $LICENSES_DIR *lic";
fi
else
echo Somethings wrong, doc...
exit 1
fi
echo Done! You can now launch CBF2
cd $BASEDIR
exit 0