forked from logicalclocks/hopsworks-chef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.sh
executable file
·256 lines (231 loc) · 5.47 KB
/
checkout.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
set -e
if [ $# -ne 1 ] ; then
echo "Usage: $0 BRANCH"
exit 2
fi
# Check that the branch name is HOPS-[0-9]+
SCRIPTNAME=`basename $0`
SCRIPTDIR=`pwd`
BASEDIR=`dirname $SCRIPTDIR`
COOKBOOK=""
REPO=""
BRANCH=$1
VERSION=$(grep -e 'version.*\".*\"' metadata.rb | sed -e 's/version//g' | sed -e 's/\"//g' | sed -e 's/^[ \t]*//')
echo "script is: $SCRIPTNAME"
echo "dir is: $SCRIPTDIR"
echo "basedir is: $BASEDIR"
echo ""
echo "Current version is: $VERSION"
echo "Enter new version: "
read ACCEPT
NEW_VERSION=$ACCEPT
echo "new version is: $NEW_VERSION"
perl -pi -e 's/$VERSION/$NEW_VERSION/g' metadata.rb
checkout()
{
pushd .
cd ../$REPO
git pull origin master
git checkout -b $BRANCH
VERSION=$(grep -e 'version.*\".*\"' metadata.rb | sed -e 's/version//g' | sed -e 's/\"//g' | sed -e 's/^[ \t]*//')
echo "Current version of $REPO is: $VERSION"
echo "Enter new version: "
read ACCEPT
NEW_VERSION=$ACCEPT
echo "new version is: $NEW_VERSION"
perl -pi -e 's/$VERSION/$NEW_VERSION/g' metadata.rb
git commit -am 'bump version to $NEW_VERSION'
git push -u origin $BRANCH
popd
perl -pi -e 's/$VERSION/$NEW_VERSION/g' Berksfile
echo "${REPO}\n" >> .${BRANCH}
}
update_hopsworks()
{
# update Berksfile to point to the new branch
perl -pi -e "s/hopshadoop\/${REPO}\",\s+branch:\s+\"master/hopshadoop\/${REPO}\", branch: \"${BRANCH}/" Berksfile
}
clear_screen()
{
echo ""
echo "Press ENTER to continue"
read cont < /dev/tty
clear
}
clone()
{
echo ""
echo "Could not find $COOKBOOK in the directory $BASEDIR "
echo ""
printf "Do you want to clone $COOKBOOK into the directory $BASEDIR ? [ yes or no ] "
read ACCEPT
case $ACCEPT in
yes | Yes | YES)
;;
no | No | NO)
echo "Exiting..."
echo ""
exit 2
;;
*)
echo ""
printf "Please enter either 'yes' or 'no'."
clone
;;
esac
# clear_screen
pushd .
cd ..
git clone [email protected]:hopshadoop/${REPO}.git
cd $REPO
git pull origin master
popd
}
# Check the user has checkout karamel-chef in the basedir
if [ ! -d $BASEDIR/karamel-chef ] ; then
echo "You need to checkout the github.com/hopshadoop/karamel-chef project into your parent dir:"
echo "cd $BASEDIR"
echo "git clone [email protected]:hopshadoop/karamel-chef.git"
echo ""
exit 12
fi
echo "Creating a new cluster configuration for $USER in karamel-chef from karamel-chef/cluster-defns/1.template.yml"
echo "New cluster configuration:"
echo "$BASEDIR/karamel-chef/cluster-defns/1.${USER}.yml"
cp -f $BASEDIR/karamel-chef/cluster-defns/1.template.yml $BASEDIR/karamel-chef/cluster-defns/1.${USER}.yml
if [ $? -ne 0 ] ; then
echo "Error copying cluster configuration file"
exit 11
fi
perl -pi -e "s/MASTER_BRANCH/${BRANCH}/" $BASEDIR/karamel-chef/cluster-defns/1.${USER}.yml
if [ $? -ne 0 ] ; then
echo "Error editing cluster configuration file"
exit 12
fi
perl -pi -e "s/THEUSER/${USER}/" $BASEDIR/karamel-chef/cluster-defns/1.${USER}.yml
if [ $? -ne 0 ] ; then
echo "Error editing cluster configuration file"
exit 13
fi
FINISHED=0
echo "" > .${BRANCH}
perl -pi -e 's/\"${VERSION}\"/\"${NEW_VERSION}\"/' metadata.rb
while [ $FINISHED -eq 0 ]; do
echo "0 FINISHED"
echo "1 conda"
echo "2 kagent"
echo "3 hops"
echo "4 ndb"
echo "5 hadoop_spark"
echo "6 flink"
echo "7 zeppelin"
echo "8 livy"
echo "9 drelephant"
echo "10 tensorflow"
echo "11 epipe"
echo "12 dela"
echo "13 kzookeeper"
echo "14 kkafka"
echo "15 elastic"
echo "16 hopslog"
echo "17 hopsmonitor"
echo "18 hive"
printf 'Enter the number of the subproject (COOKBOOK) you wish to checkout ('0' to finish): '
COOKBOOK=""
REPO=""
read ACCEPT
case $ACCEPT in
0 | "finish")
FINISHED=1
;;
1 | conda)
COOKBOOK="conda"
REPO="conda-chef"
;;
2 | kagent)
COOKBOOK="kagent"
REPO="kagent-chef"
;;
3 | hops)
COOKBOOK="hops"
REPO="hops-hadoop-chef"
;;
4 | ndb)
COOKBOOK="ndb"
REPO="ndb-chef"
;;
5 | hadoop_spark)
COOKBOOK="hadoop_spark"
REPO="spark-chef"
;;
6 | flink)
COOKBOOK="flink"
REPO="flink-chef"
;;
7 | zeppelin)
COOKBOOK="zeppelin"
REPO="zeppelin-chef"
;;
8 | livy)
COOKBOOK="livy"
REPO="livy-chef"
;;
9 | drelephant)
COOKBOOK="drelephant"
REPO="drelephant-chef"
;;
10| tensorflow)
COOKBOOK="tensorflow"
REPO="tensorflow-chef"
;;
11| epipe)
COOKBOOK="epipe"
REPO="epipe-chef"
;;
12| dela)
COOKBOOK="dela"
REPO="dela-chef"
;;
13| kzookeeper)
COOKBOOK="kzookeeper"
REPO="kzookeeper"
;;
14| kkafka)
COOKBOOK="kkafka"
REPO="kafka-chef"
;;
15| elastic)
COOKBOOK="elastic"
REPO="elastic-chef"
;;
16| hopslog)
COOKBOOK="hopslog"
REPO="hopslog-chef"
;;
17| hopsmonitor)
COOKBOOK="hopsmonitor"
REPO="hopsmonitor-chef"
;;
18| hive)
COOKBOOK="hive2"
REPO="hive-chef"
;;
*)
echo ""
echo "Invalid choice. Enter the name or number of the COOKBOOK."
;;
esac
if [ "$REPO" != "" ] ; then
echo "Cookbook chosen: $COOKBOOK"
echo ""
if [ ! -d ../$COOKBOOK ] ; then
clone
fi
checkout
update_hopsworks
fi
done
REPO="hopsworks-chef"
COOKBOOK="hopsworks"
checkout