-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
executable file
·413 lines (304 loc) · 10.9 KB
/
make.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#!/bin/sh
###############################################################################
#
# beetRoot product packager.
# Version: 4.7
#
# Notes:
# -
#
#------------------------------------------------------------------------------
#
# Copyright 2024 autumo GmbH
# Date: 02.07.2024
#
###############################################################################
# Vars
VERSION=3.1.1
# ------------------------------------------------
# -------- Usage
# ------------------------------------------------
if [ "$1" = "help" -o "$#" -lt 1 ]
then
echo " "
echo "make clear"
echo "make create"
echo " "
echo " "
echo "Deployment Notes:"
echo "- Make sure logging levels are set correctly"
echo "- Set ROOT for beetroot.sh"
echo "- Customize beetroot.sh"
echo "- Configuration will be correct."
echo " "
exit 1
fi
# ------------------------------------------------
# -------- DELETE PRODUCT
# ------------------------------------------------
if [ "$1" = "clear" ]
then
cd product
# remove working directory
if [ -d "autumo-beetRoot-$VERSION" ]
then
rm -Rf autumo-beetRoot-$VERSION
fi
if [ -d "autumo-beetRoot-web-$VERSION" ]
then
rm -Rf autumo-beetRoot-web-$VERSION
fi
# remove package
if [ -f "autumo-beetRoot-$VERSION.zip" ]
then
rm autumo-beetRoot-$VERSION.zip
fi
if [ -f "autumo-beetRoot-web-$VERSION.zip" ]
then
rm autumo-beetRoot-web-$VERSION.zip
fi
if [ -f "beetroot.war" ]
then
rm beetroot.war
fi
if [ -f "beetroot-jetty.war" ]
then
rm beetroot-jetty.war
fi
if [ -f "beetroot-weblogic.zip" ]
then
rm beetroot-weblogic.zip
fi
exit 1
fi
# ------------------------------------------------
# -------- CREATE PRODUCT
# ------------------------------------------------
if [ "$1" = "create" ]
then
# -----------------------------
# ---- Create unique secret key
# -----------------------------
HEX=`hexdump -vn16 -e'4/4 "%08x" 1 "\n"' /dev/urandom`
# -----------------------------
# ---- Pack & copy libs
# -----------------------------
echo "-> Pack and copy newest beetroot lib..."
# package beetroot
mkdir -p lib/repo/ch/autumo/beetroot/autumo-beetroot/$VERSION
mvn clean
mvn install
# -----------------------------
# ---- Cleanup & Prepare
# -----------------------------
echo "-> Cleanup & prepare..."
# delete old product package
if [ -f "product/autumo-beetRoot-$VERSION.zip" ]
then
rm product/autumo-beetRoot-$VERSION.zip
fi
if [ -f "product/autumo-beetRoot-web-$VERSION.zip" ]
then
rm product/autumo-beetRoot-web-$VERSION.zip
fi
# go to product
cd product
# make working directory
mkdir autumo-beetRoot-$VERSION
mkdir autumo-beetRoot-web-$VERSION
# -----------------------------
# ---- Licenses
# -----------------------------
echo "-> Copying 3rd party licenses..."
mkdir autumo-beetRoot-$VERSION/etc
mkdir autumo-beetRoot-$VERSION/etc/licenses
cp ../etc/licenses/* autumo-beetRoot-$VERSION/etc/licenses
# -----------------------------
# ---- Copying config
# -----------------------------
echo "-> Copying config..."
mkdir autumo-beetRoot-$VERSION/cfg
cp ../cfg/beetroot_dist.cfg autumo-beetRoot-$VERSION/cfg/beetroot.cfg
cp ../cfg/languages.cfg autumo-beetRoot-$VERSION/cfg/languages.cfg
cp ../cfg/routing.xml autumo-beetRoot-$VERSION/cfg/routing.xml
#mkdir autumo-beetRoot-$VERSION/doc
#cp ../doc autumo-beetRoot-$VERSION/doc
mkdir autumo-beetRoot-web-$VERSION/WEB-INF
mkdir autumo-beetRoot-web-$VERSION/META-INF
mkdir autumo-beetRoot-web-$VERSION/META-INF/etc
mkdir autumo-beetRoot-web-$VERSION/META-INF/etc/licenses
cp ../cfg/beetroot_dist.cfg autumo-beetRoot-web-$VERSION/beetroot.cfg
cp ../cfg/languages.cfg autumo-beetRoot-web-$VERSION/languages.cfg
cp ../cfg/routing.xml autumo-beetRoot-web-$VERSION/routing.xml
cp ../cfg/context.xml autumo-beetRoot-web-$VERSION/META-INF/context.xml
cp ../cfg/web.xml autumo-beetRoot-web-$VERSION/WEB-INF/web.xml
cp ../LICENSE.md autumo-beetRoot-web-$VERSION/META-INF/etc/
cp ../etc/licenses/*.* autumo-beetRoot-web-$VERSION/META-INF/etc/licenses/
# -----------------------------
# ---- Copying logging config
# -----------------------------
echo "-> Copying logging config..."
cp ../cfg/logging-dist.xml autumo-beetRoot-$VERSION/cfg/logging.xml
cp ../cfg/logging-web.xml autumo-beetRoot-web-$VERSION/logging.xml
# -----------------------------
# ---- General copying & signing
# -----------------------------
echo "-> Making directories and copying..."
# replace productive passwords!
#for file in interfaces/templates/*.ifacex
#do
# sed -i '' 's/rest_in_api_key=.*/rest_in_api_key=<YOUR_OWN_API_KEY>/' $file
#
#done
# copy libs
mkdir autumo-beetRoot-$VERSION/lib
cp ../lib/*.jar autumo-beetRoot-$VERSION/lib/
mkdir -p autumo-beetRoot-$VERSION/lib/repo/ch/autumo/beetroot/autumo-beetroot/$VERSION
# Copy autumo-beetroot to local repo
cp ../lib/autumo-beetroot-$VERSION.jar autumo-beetRoot-$VERSION/lib/repo/ch/autumo/beetroot/autumo-beetroot/$VERSION/
# Copy local repo for dev (not yet public maven libs)
cp -R ../lib/repo autumo-beetRoot-$VERSION/lib/
mkdir autumo-beetRoot-web-$VERSION/WEB-INF/lib
cp ../lib/*.jar autumo-beetRoot-web-$VERSION/WEB-INF/lib/
# Servlet API not needed in web-containers!
rm autumo-beetRoot-web-$VERSION/WEB-INF/lib/javax.servlet-api*.jar
#echo "-> Signing libs..."
#jarsigner -storepass xxxxx -keystore ../cfg/KeyStore.jks -tsa http://tsa.pki.admin.ch/tsa autumo-beetRoot-$VERSION/lib/autumo-beetroot-${VERSION}.jar autumo.ch
# make empty dirs
mkdir autumo-beetRoot-$VERSION/log
# --------- H2 DB
mkdir autumo-beetRoot-$VERSION/db
cd autumo-beetRoot-$VERSION/db
mkdir h2
cd h2
mkdir db
cd ..
cd ..
cd ..
cp ../db/h2/h2* autumo-beetRoot-$VERSION/db/h2/
cp ../db/h2/db/dist/* autumo-beetRoot-$VERSION/db/h2/db/
cp ../db/*.sql autumo-beetRoot-$VERSION/db/
mkdir autumo-beetRoot-web-$VERSION/db
cd autumo-beetRoot-web-$VERSION/db
mkdir h2
cd h2
mkdir db
cd ..
cd ..
cd ..
cp ../db/h2/h2* autumo-beetRoot-web-$VERSION/db/h2/
cp ../db/h2/db/dist/* autumo-beetRoot-web-$VERSION/db/h2/db/
cp ../db/*.sql autumo-beetRoot-web-$VERSION/db/
# --------- Gen resources
mkdir autumo-beetRoot-$VERSION/gen
cp -r ../gen autumo-beetRoot-$VERSION/
# --------- Web resources
mkdir autumo-beetRoot-$VERSION/web
cp -r ../web autumo-beetRoot-$VERSION/
cp -r ../web autumo-beetRoot-web-$VERSION/
# --------- SSL resources
mkdir autumo-beetRoot-$VERSION/ssl
cp -r ../ssl autumo-beetRoot-$VERSION/
cp -r ../ssl autumo-beetRoot-web-$VERSION/
# --------- Copy scripts
mkdir autumo-beetRoot-$VERSION/bin
cp ../bin/pwencoder.sh autumo-beetRoot-$VERSION/bin
cp ../bin/pwencoder.bat autumo-beetRoot-$VERSION/bin
cp ../bin/beetroot.sh autumo-beetRoot-$VERSION/bin
cp ../bin/beetroot.bat autumo-beetRoot-$VERSION/bin
cp ../bin/plant.sh autumo-beetRoot-$VERSION/bin
cp ../bin/plant.bat autumo-beetRoot-$VERSION/bin
cp ../bin/version.sh autumo-beetRoot-$VERSION/bin
cp ../bin/version.bat autumo-beetRoot-$VERSION/bin
# --------- Copy infos
mkdir autumo-beetRoot-$VERSION/doc
mkdir autumo-beetRoot-$VERSION/doc/migration
cp ../doc/*.md autumo-beetRoot-$VERSION/doc
cp ../doc/migration/*.md autumo-beetRoot-$VERSION/doc/migration/
cp ../README.md autumo-beetRoot-$VERSION/
cp ../LICENSE.md autumo-beetRoot-$VERSION/
cp ../THIRDPARTYLICENSES.html autumo-beetRoot-$VERSION/
# Copy dev pom.xml
cp ../etc/pom/pom.xml autumo-beetRoot-$VERSION/
cp ../README.md autumo-beetRoot-web-$VERSION/
cp ../LICENSE.md autumo-beetRoot-web-$VERSION/
cp ../THIRDPARTYLICENSES.html autumo-beetRoot-web-$VERSION/
# -----------------------------
# ---- Create Product
# -----------------------------
echo "-> Create PRODUCT..."
# -- Replace unique secret key (seed)
sed -i '' "s/secret_key_seed=.*/secret_key_seed=$HEX/" autumo-beetRoot-${VERSION}/cfg/beetroot.cfg
# create archive
zip -r "autumo-beetRoot-${VERSION}.zip" autumo-beetRoot-${VERSION} \
-x "*/.gitignore" \
-x "*/.DS_Store" \
-x "*/__MACOSX"
cd autumo-beetRoot-web-${VERSION}
# add servlet context variable to db url
sed -i '' 's|db_url=jdbc:h2.*|db_url=jdbc:h2:[WEB-CONTEXT-PATH]/db/h2/db/beetroot|' beetroot.cfg
# -- Replace unique secret key (seed)
sed -i '' "s/secret_key_seed=.*/secret_key_seed=$HEX/" beetroot.cfg
cd ..
# create archive
zip -r "autumo-beetRoot-web-${VERSION}.zip" autumo-beetRoot-web-${VERSION} \
-x "*/.gitignore" \
-x "*/.DS_Store" \
-x "*/__MACOSX"
# -- BUILD container products
# -- 1. Tomcat
cd autumo-beetRoot-web-${VERSION}
# change port (used for email templates)
sed -i '' 's/ws_port=.*/ws_port=8080/' beetroot.cfg
# add servlet name for WAR version!
sed -i '' 's/web_html_ref_pre_url_part=/web_html_ref_pre_url_part=beetroot/' beetroot.cfg
jar --create --file "beetroot.war" *
mv *.war ../
cd ..
# -- 2. WebLogic
cp ../cfg/weblogic.xml autumo-beetRoot-web-${VERSION}/WEB-INF/weblogic.xml
cp ../cfg/logging-web-weblogic.xml autumo-beetRoot-web-${VERSION}/logging.xml
# change port (used for email templates)
sed -i '' 's/ws_port=.*/ws_port=7001/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
# Use Javax for mailing
sed -i '' 's/mail_implementation=.*/mail_implementation=javax/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
sed -i '' 's/mail_session_name=.*/mail_session_name=beetRootMailSession/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
# Pack it
mkdir beetroot/
cp -R autumo-beetRoot-web-${VERSION}/* beetroot/
zip -r "beetroot-weblogic.zip" beetroot/ \
-x "*/.gitignore" \
-x "*/.DS_Store" \
-x "*/__MACOSX"
rm -fR beetroot/
# -- 3. Jetty
rm -f autumo-beetRoot-web-${VERSION}/WEB-INF/weblogic.xml
cp ../cfg/web-jetty.xml autumo-beetRoot-web-$VERSION/WEB-INF/web.xml
cp ../cfg/jetty-web.xml autumo-beetRoot-web-$VERSION/WEB-INF/jetty-web.xml
# Replace logging implementation!
(cd autumo-beetRoot-web-$VERSION/WEB-INF/lib && curl -LO https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar)
rm autumo-beetRoot-web-$VERSION/WEB-INF/lib/log4j-slf4j-impl-*.jar
rm -f autumo-beetRoot-web-$VERSION/logging.xml
#rm -f autumo-beetRoot-web-$VERSION/WEB-INF/lib/log4j*
# no AUTO_SERVER=TRUE switch
sed -i '' 's|db_url=jdbc:h2:.*|db_url=jdbc:h2:[WEB-CONTEXT-PATH]/db/h2/db/beetroot;IFEXISTS=TRUE|' autumo-beetRoot-web-${VERSION}/beetroot.cfg
# Change back mailing implementation
sed -i '' 's/mail_implementation=.*/mail_implementation=jakarta/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
sed -i '' 's/mail_session_name=.*/mail_session_name=/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
# change port (used for email templates)
sed -i '' 's/ws_port=.*/ws_port=8080/' autumo-beetRoot-web-${VERSION}/beetroot.cfg
cd autumo-beetRoot-web-${VERSION}
jar --create --file "beetroot-jetty.war" *
mv *.war ../
cd ..
rm -Rf autumo-beetRoot-$VERSION
rm -Rf autumo-beetRoot-web-$VERSION
# -----------------------------
# ---- END
# -----------------------------
# leave product folder
cd ..
else
echo "Nope! -> make create|clear "
echo " "
fi