forked from HCL-TECH-SOFTWARE/domino-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·1344 lines (1061 loc) · 31.8 KB
/
build.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
############################################################################
# Copyright Nash!Com, Daniel Nashed 2019, 2020 - APACHE 2.0 see LICENSE
# Copyright IBM Corporation 2015, 2022 - APACHE 2.0 see LICENSE
############################################################################
# Version 2.0
# Main Script to build images.
# Run without parameters for detailed syntax.
# The script checks if software is available at configured location (download location or local directory).
# In case of a local software directory it hosts the software on a local NGINX container.
SCRIPT_NAME=$0
# Standard configuration overwritten by build.cfg
# (Default) NGINX is used hosting software from the local "software" directory.
# Default: Update CentOS while building the image
LinuxYumUpdate=yes
# Default: Check if software exits
CHECK_SOFTWARE=yes
# ----------------------------------------
log_error_exit()
{
echo
echo $@
echo
exit 1
}
check_version()
{
count=1
while true
do
VER=$(echo $1|cut -d"." -f $count)
CHECK=$(echo $2|cut -d"." -f $count)
if [ -z "$VER" ]; then return 0; fi
if [ -z "$CHECK" ]; then return 0; fi
if [ $VER -gt $CHECK ]; then return 0; fi
if [ $VER -lt $CHECK ]; then
echo "Warning: Unsupported $3 version $1 - Must be at least $2 !"
sleep 1
return 1
fi
count=$(expr $count + 1)
done
return 0
}
check_timezone()
{
LARCH=$(uname)
echo
# If Timezone is not set use host's timezone
if [ -z $DOCKER_TZ ]; then
if [ $LARCH = "Linux" ]; then
DOCKER_TZ=$(readlink /etc/localtime | awk -F'/usr/share/zoneinfo/' '{print $2}')
elif [ $LARCH = "Darwin" ]; then
DOCKER_TZ=$(readlink /etc/localtime | awk -F'/usr/share/zoneinfo/' '{print $2}')
else
DOCKER_TZ=""
fi
echo "Using OS Timezone : [$DOCKER_TZ]"
else
echo "Timezone configured: [$DOCKER_TZ]"
fi
echo
return 0
}
get_container_environment()
{
# If specified use specified command. Else find out the platform.
if [ -n "$CONTAINER_CMD" ]; then
return 0
fi
if [ -n "$USE_DOCKER" ]; then
CONTAINER_CMD=docker
return 0
fi
if [ -x /usr/bin/podman ]; then
CONTAINER_CMD=podman
return 0
fi
if [ -n "$(which nerdctl 2> /dev/null)" ]; then
CONTAINER_CMD=nerdctl
return 0
fi
CONTAINER_CMD=docker
return 0
}
check_container_environment()
{
DOCKER_MINIMUM_VERSION="18.09.0"
PODMAN_MINIMUM_VERSION="1.5.0"
if [ "$CONTAINER_CMD" = "podman" ]; then
DOCKER_ENV_NAME=Podman
DOCKER_VERSION_STR=$(podman -v | head -1)
DOCKER_VERSION=$(echo $DOCKER_VERSION_STR | awk -F'version ' '{print $2 }')
check_version "$DOCKER_VERSION" "$PODMAN_MINIMUM_VERSION" "$CONTAINER_CMD"
if [ -z "$DOCKER_NETWORK" ]; then
if [ -n "$DOCKER_NETWORK_NAME" ]; then
CONTAINER_NETWORK_CMD="--network=$CONTAINER_NETWORK_NAME"
fi
fi
return 0
fi
if [ "$CONTAINER_CMD" = "docker" ]; then
DOCKER_ENV_NAME=Docker
if [ -z "$DOCKERD_NAME" ]; then
DOCKERD_NAME=dockerd
fi
# check docker environment
DOCKER_VERSION_STR=$(docker -v | head -1)
DOCKER_VERSION=$(echo $DOCKER_VERSION_STR | awk -F'version ' '{print $2 }'|cut -d"," -f1)
check_version "$DOCKER_VERSION" "$DOCKER_MINIMUM_VERSION" "$CONTAINER_CMD"
# Use sudo for docker command if not root on Linux
if [ $(uname) = "Linux" ]; then
if [ ! "$EUID" = "0" ]; then
if [ "$DOCKER_USE_SUDO" = "no" ]; then
log_error_exit "Docker needs root permissions on Linux!"
fi
CONTAINER_CMD="sudo $CONTAINER_CMD"
fi
fi
if [ -z "$DOCKER_NETWORK" ]; then
if [ -n "$DOCKER_NETWORK_NAME" ]; then
CONTAINER_NETWORK_CMD="--network=$CONTAINER_NETWORK_NAME"
fi
fi
return 0
fi
if [ "$CONTAINER_CMD" = "nerdctl" ]; then
DOCKER_ENV_NAME=nerdctl
if [ -z "$CONTAINER_NAMESPACE" ]; then
CONTAINER_NAMESPACE=k8s.io
fi
CONTAINER_NAMESPACE_CMD="--namespace=$CONTAINER_NAMESPACE"
DOCKER_VERSION_STR=$(nerdctl -v | head -1)
DOCKER_VERSION=$(echo $DOCKER_VERSION_STR | awk -F'version ' '{print $2 }')
fi
return 0
}
usage()
{
echo
echo "Usage: $(basename $SCRIPT_NAME) { domino | traveler | volt } version fp hf"
echo
echo "-checkonly checks without build"
echo "-verifyonly checks download file checksum without build"
echo "-(no)check checks if files exist (default: yes)"
echo "-(no)verify checks downloaded file checksum (default: no)"
echo "-(no)url shows all download URLs, even if file is downloaded (default: no)"
echo "-(no)linuxupd updates container Linux while building image (default: yes)"
echo "cfg|config edits config file (either in current directory or if created in home dir)"
echo "cpcfg copies standard config file to config directory (default: $CONFIG_FILE)"
echo
echo "-tag=<image> additional image tag"
echo "-push=<image> tag and push image to registry"
echo
echo Add-On options
echo
echo "-from=<image> builds from a specified build image. there are named images like 'ubi' predefined"
echo "-openssl adds OpenSSL to Domino image"
echo "-borg adds borg client and Domino Borg Backup integration to image"
echo "-verse adds the latest verse version to a Domino image"
echo "-capi adds the C-API sdk/toolkit to a Domino image"
echo "-k8s-runas adds K8s runas user support"
echo "-startscript=x installs specified start script version from software repository"
echo
echo
echo "Examples:"
echo
echo " $(basename $SCRIPT_NAME) domino 12.0.1 if1"
echo " $(basename $SCRIPT_NAME) traveler 12.0.1"
echo
return 0
}
print_delim()
{
echo "--------------------------------------------------------------------------------"
}
header()
{
echo
print_delim
echo "$1"
print_delim
echo
}
dump_config()
{
header "Build Configuration"
echo "Build Environment : [$CONTAINER_CMD]"
echo "BASE_IMAGE : [$BASE_IMAGE]"
echo "DOWNLOAD_FROM : [$DOWNLOAD_FROM]"
echo "SOFTWARE_DIR : [$SOFTWARE_DIR]"
echo "PROD_NAME : [$PROD_NAME]"
echo "PROD_VER : [$PROD_VER]"
echo "PROD_FP : [$PROD_FP]"
echo "PROD_HF : [$PROD_HF]"
echo "PROD_EXT : [$PROD_EXT]"
echo "CHECK_SOFTWARE : [$CHECK_SOFTWARE]"
echo "CHECK_HASH : [$CHECK_HASH]"
echo "DOWNLOAD_URLS_SHOW : [$DOWNLOAD_URLS_SHOW]"
echo "TAG_LATEST : [$TAG_LATEST]"
echo "TAG_IMAGE : [$TAG_IMAGE]"
echo "PUSH_IMAGE : [$PUSH_IMAGE]"
echo "DOCKER_FILE : [$DOCKER_FILE]"
echo "VERSE_VERSION : [$VERSE_VERSION]"
echo "CAPI_VERSION : [$CAPI_VERSION]"
echo "STARTSCRIPT_VER : [$STARTSCRIPT_VER]"
echo "LinuxYumUpdate : [$LinuxYumUpdate]"
echo "DOMINO_LANG : [$DOMINO_LANG]"
echo "NAMESPACE : [$CONTAINER_NAMESPACE]"
echo "K8S_RUNAS_USER : [$K8S_RUNAS_USER_SUPPORT]"
echo
return 0
}
nginx_start()
{
# Create a nginx container hosting software download locally
# Check if we already have this container in status exited
STATUS="$($CONTAINER_CMD inspect --format '{{ .State.Status }}' $SOFTWARE_CONTAINER 2>/dev/null)"
if [ -z "$STATUS" ]; then
echo "Creating Docker container: $SOFTWARE_CONTAINER hosting [$SOFTWARE_DIR]"
$CONTAINER_CMD run --name $SOFTWARE_CONTAINER -p $SOFTWARE_PORT:80 -v $SOFTWARE_DIR:/usr/share/nginx/html:Z -d nginx
elif [ "$STATUS" = "exited" ]; then
echo "Starting existing Docker container: $SOFTWARE_CONTAINER"
$CONTAINER_CMD start $SOFTWARE_CONTAINER
fi
echo "Starting Docker container: $SOFTWARE_CONTAINER"
# Start local nginx container to host SW Repository
SOFTWARE_REPO_IP="$($CONTAINER_CMD inspect --format '{{ .NetworkSettings.IPAddress }}' $SOFTWARE_CONTAINER 2>/dev/null)"
if [ -z "$SOFTWARE_REPO_IP" ]; then
echo "No specific IP address using host address"
SOFTWARE_REPO_IP=$(hostname --all-ip-addresses | cut -f1 -d" "):$SOFTWARE_PORT
fi
DOWNLOAD_FROM=http://$SOFTWARE_REPO_IP
echo "Hosting HCL Software repository on $DOWNLOAD_FROM"
echo
}
nginx_stop()
{
# Stop and remove SW repository
$CONTAINER_CMD stop $SOFTWARE_CONTAINER
$CONTAINER_CMD container rm $SOFTWARE_CONTAINER
echo "Stopped & Removed Software Repository Container"
echo
}
print_runtime()
{
hours=$((SECONDS / 3600))
seconds=$((SECONDS % 3600))
minutes=$((seconds / 60))
seconds=$((seconds % 60))
h=""; m=""; s=""
if [ ! $hours = "1" ] ; then h="s"; fi
if [ ! $minutes = "1" ] ; then m="s"; fi
if [ ! $seconds = "1" ] ; then s="s"; fi
if [ ! $hours = 0 ] ; then echo "Completed in $hours hour$h, $minutes minute$m and $seconds second$s"
elif [ ! $minutes = 0 ] ; then echo "Completed in $minutes minute$m and $seconds second$s"
else echo "Completed in $seconds second$s"; fi
}
get_current_version()
{
if [ -n "$DOWNLOAD_FROM" ]; then
DOWNLOAD_FILE=$DOWNLOAD_FROM/$VERSION_FILE_NAME
CURL_RET=$($CURL_CMD "$DOWNLOAD_FILE" --silent --head 2>&1)
STATUS_RET=$(echo $CURL_RET | grep 'HTTP/1.1 200 OK')
if [ -n "$STATUS_RET" ]; then
DOWNLOAD_VERSION_FILE=$DOWNLOAD_FILE
fi
fi
if [ -n "$DOWNLOAD_VERSION_FILE" ]; then
echo "Getting current software version from [$DOWNLOAD_VERSION_FILE]"
LINE=$($CURL_CMD --silent $DOWNLOAD_VERSION_FILE | grep "^$1|")
else
if [ ! -r "$VERSION_FILE" ]; then
echo "No current version file found! [$VERSION_FILE]"
else
echo "Getting current software version from [$VERSION_FILE]"
LINE=$(grep "^$1|" $VERSION_FILE)
fi
fi
PROD_VER=$(echo $LINE|cut -d'|' -f2)
PROD_FP=$(echo $LINE|cut -d'|' -f3)
PROD_HF=$(echo $LINE|cut -d'|' -f4)
return 0
}
get_current_addon_version()
{
local S1=$2
local S2=${!2}
if [ -n "$DOWNLOAD_FROM" ]; then
DOWNLOAD_FILE=$DOWNLOAD_FROM/$VERSION_FILE_NAME
echo "getting current add-on version from: [$DOWNLOAD_FILE]"
CURL_RET=$($CURL_CMD "$DOWNLOAD_FILE" --silent --head 2>&1)
STATUS_RET=$(echo $CURL_RET | grep 'HTTP/1.1 200 OK')
if [ -n "$STATUS_RET" ]; then
DOWNLOAD_VERSION_FILE=$DOWNLOAD_FILE
fi
fi
if [ -n "$DOWNLOAD_VERSION_FILE" ]; then
echo "Getting current add-on version from [$DOWNLOAD_VERSION_FILE]"
LINE=$($CURL_CMD --silent $DOWNLOAD_VERSION_FILE | grep "^$1|")
else
if [ ! -r "$VERSION_FILE" ]; then
echo "No current version file found! [$VERSION_FILE]"
else
echo "Getting current software version from [$VERSION_FILE]"
LINE=$(grep "^$1|" $VERSION_FILE)
fi
fi
export $2=$(echo $LINE|cut -d'|' -f2 -s)
return 0
}
copy_config_file()
{
if [ -e "$CONFIG_FILE" ]; then
echo "Config File [$CONFIG_FILE] already exists!"
return 0
fi
mkdir -p $DOMINO_DOCKER_CFG_DIR
if [ -e "$BUILD_CFG_FILE" ]; then
cp "$BUILD_CFG_FILE" "$CONFIG_FILE"
else
echo "Cannot copy config file"
fi
}
edit_config_file()
{
if [ ! -e "$CONFIG_FILE" ]; then
echo "Creating new config file [$CONFIG_FILE]"
copy_config_file
fi
$EDIT_COMMAND $CONFIG_FILE
}
check_for_hcl_image()
{
# If the base is the HCL Domino image,
# Also bypass software download check.
# But check if the image is available.
case "$FROM_IMAGE" in
domino-docker*)
LINUX_NAME="HCL Base Image"
BASE_IMAGE=$FROM_IMAGE
;;
*)
return 0
;;
esac
IMAGE_ID=$($CONTAINER_CMD $CONTAINER_NAMESPACE_CMD images $BASE_IMAGE -q)
if [ -z "$IMAGE_ID" ]; then
log_error_exit "Base image [$FROM_IMAGE] does not exist"
fi
# Derive version from Docker image name
PROD_NAME=domino
PROD_VER=$(echo $FROM_IMAGE | cut -d":" -f 2 -s)
# don't check software
CHECK_SOFTWARE=no
CHECK_HASH=no
}
check_from_image()
{
if [ -z "$FROM_IMAGE" ]; then
if [ "$PROD_NAME" = "domino" ]; then
LINUX_NAME="CentOS Stream"
BASE_IMAGE=quay.io/centos/centos:stream8
else
BASE_IMAGE=hclcom/domino:latest
fi
return 0
fi
case "$FROM_IMAGE" in
centos8)
LINUX_NAME="CentOS Stream"
BASE_IMAGE=quay.io/centos/centos:stream8
;;
centos9)
LINUX_NAME="CentOS Stream 9"
BASE_IMAGE=quay.io/centos/centos:stream9
;;
rocky)
LINUX_NAME="Rocky Linux"
BASE_IMAGE=rockylinux/rockylinux
;;
alma)
LINUX_NAME="Alma Linux"
BASE_IMAGE=almalinux/almalinux:8
;;
amazon)
LINUX_NAME="Amazon Linux"
BASE_IMAGE=amazonlinux
;;
oracle)
LINUX_NAME="Oracle Linux"
BASE_IMAGE=oraclelinux:8
;;
photon)
LINUX_NAME="Photon OS"
BASE_IMAGE=photon
;;
ubi)
LINUX_NAME="RedHat UBI"
BASE_IMAGE=redhat/ubi8
;;
leap)
LINUX_NAME="SUSE Leap"
BASE_IMAGE=opensuse/leap
;;
astra)
LINUX_NAME="Astra Linux"
BASE_IMAGE=orel:latest
;;
*)
LINUX_NAME="Manual specified base image"
BASE_IMAGE=$FROM_IMAGE
echo "Info: Manual specified base image used! [$FROM_IMAGE]"
;;
esac
header "Base Image - $LINUX_NAME"
}
build_domino()
{
CONTAINER_DESCRIPTION="HCL Domino Enterprise Server"
$CONTAINER_CMD build --no-cache \
$CONTAINER_NETWORK_CMD $CONTAINER_NAMESPACE_CMD \
-t $DOCKER_IMAGE \
-f $DOCKER_FILE \
--label maintainer="thomas.hampel, daniel.nashed@nashcom.de" \
--label name="HCL Domino Community Image" \
--label vendor="Domino Docker Community Project" \
--label description="$CONTAINER_DESCRIPTION" \
--label summary="$CONTAINER_DESCRIPTION" \
--label version="$DOCKER_IMAGE_VERSION" \
--label "buildtime"="$BUILDTIME" \
--label release="$BUILDTIME" \
--label architecture="x86_64" \
--label "io.k8s.description"="HCL Domino Community Image" \
--label "io.k8s.display-name"="HCL Domino Community Image" \
--label io.openshift.expose-services="1352:nrpc 80:http 110:pop3 143:imap 389:ldap 443:https 636:ldaps 993:imaps 995:pop3s" \
--label io.openshift.tags="domino" \
--label io.openshift.non-scalable=true \
--label io.openshift.min-memory=2Gi \
--label io.openshift.min-cpu=2 \
--label DominoDocker.maintainer="thomas.hampel, daniel.nashed@nashcom.de" \
--label DominoDocker.description="$DOCKER_DESCRIPTION" \
--label DominoDocker.version="$DOCKER_IMAGE_VERSION" \
--label DominoDocker.buildtime="$BUILDTIME" \
--build-arg PROD_NAME=$PROD_NAME \
--build-arg PROD_VER=$PROD_VER \
--build-arg PROD_FP=$PROD_FP \
--build-arg PROD_HF=$PROD_HF \
--build-arg DOCKER_TZ=$DOCKER_TZ \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg DownloadFrom=$DOWNLOAD_FROM \
--build-arg LinuxYumUpdate=$LinuxYumUpdate \
--build-arg OPENSSL_INSTALL="$OPENSSL_INSTALL" \
--build-arg BORG_INSTALL="$BORG_INSTALL" \
--build-arg VERSE_VERSION="$VERSE_VERSION" \
--build-arg CAPI_VERSION="$CAPI_VERSION" \
--build-arg STARTSCRIPT_VER="$STARTSCRIPT_VER" \
--build-arg DOMINO_LANG="$DOMINO_LANG" \
--build-arg K8S_RUNAS_USER_SUPPORT="$K8S_RUNAS_USER_SUPPORT" \
--build-arg SPECIAL_CURL_ARGS="$SPECIAL_CURL_ARGS" .
}
build_traveler()
{
CONTAINER_DESCRIPTION="HCL Traveler"
$CONTAINER_CMD build --no-cache \
$CONTAINER_NETWORK_CMD $CONTAINER_NAMESPACE_CMD \
-t $DOCKER_IMAGE \
-f $DOCKER_FILE \
--label maintainer="thomas.hampel, daniel.nashed@nashcom.de" \
--label name="HCL Traveler Community Image" \
--label vendor="Domino Docker Community Project" \
--label description="HCL Traveler Mobile Sync Server" \
--label summary="HCL Traveler Mobile Sync Server" \
--label version="$DOCKER_IMAGE_VERSION" \
--label "buildtime"="$BUILDTIME" \
--label release="$BUILDTIME" \
--label architecture="x86_64" \
--label "io.k8s.description"="HCL Traveler Community Image" \
--label "io.k8s.display-name"="HCL Traveler Community Image" \
--label io.openshift.expose-services="1352:nrpc 25:smtp 80:http 389:ldap 443:https 636:ldaps" \
--label TravelerDocker.description="$CONTAINER_DESCRIPTION" \
--label TravelerDocker.version="$DOCKER_IMAGE_VERSION" \
--label TravelerDocker.buildtime="$BUILDTIME" \
--build-arg PROD_NAME="$PROD_NAME" \
--build-arg PROD_VER="$PROD_VER" \
--build-arg DownloadFrom="$DOWNLOAD_FROM" \
--build-arg LinuxYumUpdate="$LinuxYumUpdate" \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg SPECIAL_CURL_ARGS="$SPECIAL_CURL_ARGS" .
}
build_volt()
{
CONTAINER_DESCRIPTION="HCL Volt"
$CONTAINER_CMD build --no-cache \
$CONTAINER_NETWORK_CMD $CONTAINER_NAMESPACE_CMD \
-t $DOCKER_IMAGE \
-f $DOCKER_FILE \
--label maintainer="thomas.hampel, daniel.nashed@nashcom.de" \
--label name="HCL Volt Community Image" \
--label vendor="Domino Docker Community Project" \
--label description="HCL Volt - Low Code platform" \
--label summary="HCL Volt - Low Code platform" \
--label version="$DOCKER_IMAGE_VERSION" \
--label "buildtime"="$BUILDTIME" \
--label release="$BUILDTIME" \
--label architecture="x86_64" \
--label "io.k8s.description"="HCL Volt Community Image" \
--label "io.k8s.display-name"="HCL Volt Community Image" \
--label io.openshift.expose-services="1352:nrpc 25:smtp 80:http 389:ldap 443:https 636:ldaps" \
--label VoltDocker.description="$CONTAINER_DESCRIPTION" \
--label VoltDocker.version="$DOCKER_IMAGE_VERSION" \
--label VoltDocker.buildtime="$BUILDTIME" \
--build-arg PROD_NAME="$PROD_NAME" \
--build-arg PROD_VER="$PROD_VER" \
--build-arg DownloadFrom="$DOWNLOAD_FROM" \
--build-arg LinuxYumUpdate="$LinuxYumUpdate" \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg SPECIAL_CURL_ARGS="$SPECIAL_CURL_ARGS" .
}
docker_build()
{
# Get product name from file name
if [ -z $PROD_NAME ]; then
log_error_exit "No product specified"
fi
if [ -z "$DOWNLOAD_FROM" ]; then
log_error_exit "No download location specified!"
fi
CUSTOM_VER=$(echo "$CUSTOM_VER" | awk '{print toupper($0)}')
CUSTOM_FP=$(echo "$CUSTOM_FP" | awk '{print toupper($0)}')
CUSTOM_HF=$(echo "$CUSTOM_HF" | awk '{print toupper($0)}')
if [ -n "$CUSTOM_VER" ]; then
PROD_VER=$CUSTOM_VER
PROD_FP=$CUSTOM_FP
PROD_HF=$CUSTOM_HF
fi
DOCKER_IMAGE_NAME="hclcom/$PROD_NAME"
DOCKER_IMAGE_VERSION=$PROD_VER$PROD_FP$PROD_HF$PROD_EXT
# Set default or custom LATEST tag
if [ -n "$TAG_LATEST" ]; then
DOCKER_TAG_LATEST="$DOCKER_IMAGE_NAME:$TAG_LATEST"
fi
if [ "$CONTAINER_CMD" = "nerdctl" ]; then
# Currently nerdctl cannot handle a second tag
DOCKER_TAG_LATEST=
fi
echo "Building Image : " $IMAGENAME
# Get Build Time
BUILDTIME=$(date +"%d.%m.%Y %H:%M:%S")
# Get build arguments
DOCKER_IMAGE=$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_VERSION
# Switch to directory containing the dockerfiles
cd dockerfiles
DOCKER_IMAGE_BUILD_VERSION=$DOCKER_IMAGE_VERSION
export BUILDAH_FORMAT
case "$PROD_NAME" in
domino)
if [ -z "$DOCKER_FILE" ]; then
DOCKER_FILE=dockerfile
fi
build_domino
;;
traveler)
DOCKER_FILE=dockerfile_traveler
build_traveler
;;
volt)
DOCKER_FILE=dockerfile_volt
build_volt
;;
*)
log_error_exit "Unknown product [$PROD_NAME] - Terminating installation"
;;
esac
if [ ! "$?" = "0" ]; then
log_error_exit "Image build failed!"
fi
if [ -n "$DOCKER_TAG_LATEST" ]; then
$CONTAINER_CMD tag $DOCKER_IMAGE $DOCKER_TAG_LATEST
echo
fi
if [ -n "$TAG_IMAGE" ]; then
$CONTAINER_CMD tag $DOCKER_IMAGE $TAG_IMAGE
echo
fi
if [ -n "$PUSH_IMAGE" ]; then
$CONTAINER_CMD tag $DOCKER_IMAGE $PUSH_IMAGE
header "Pushing image $PUSH_IMAGE to registry"
$CONTAINER_CMD push $PUSH_IMAGE
echo
fi
echo
return 0
}
check_software()
{
CURRENT_NAME=$(echo $1|cut -d'|' -f1)
CURRENT_VER=$(echo $1|cut -d'|' -f2)
CURRENT_FILES=$(echo $1|cut -d'|' -f3)
CURRENT_PARTNO=$(echo $1|cut -d'|' -f4)
CURRENT_HASH=$(echo $1|cut -d'|' -f5)
if [ -z "$DOWNLOAD_FROM" ]; then
FOUND=
DOWNLOAD_1ST_FILE=
for CHECK_FILE in $(echo "$CURRENT_FILES" | tr "," "\n"); do
if [ -z "$DOWNLOAD_1ST_FILE" ]; then
DOWNLOAD_1ST_FILE=$CHECK_FILE
fi
if [ -r "$SOFTWARE_DIR/$CHECK_FILE" ]; then
CURRENT_FILE="$CHECK_FILE"
FOUND=TRUE
break
fi
done
if [ "$FOUND" = "TRUE" ]; then
if [ -z "$CURRENT_HASH" ]; then
CURRENT_STATUS="NA"
else
if [ ! "$CHECK_HASH" = "yes" ]; then
CURRENT_STATUS="OK"
else
HASH=$(sha256sum $SOFTWARE_DIR/$CURRENT_FILE -b | cut -d" " -f1)
if [ "$CURRENT_HASH" = "$HASH" ]; then
CURRENT_STATUS="OK"
else
CURRENT_STATUS="CR"
fi
fi
fi
else
CURRENT_STATUS="NA"
fi
else
FOUND=
DOWNLOAD_1ST_FILE=
for CHECK_FILE in $(echo "$CURRENT_FILES" | tr "," "\n") ; do
if [ -z "$DOWNLOAD_1ST_FILE" ]; then
DOWNLOAD_1ST_FILE=$CHECK_FILE
fi
DOWNLOAD_FILE=$DOWNLOAD_FROM/$CHECK_FILE
CURL_RET=$($CURL_CMD "$DOWNLOAD_FILE" --silent --head 2>&1)
STATUS_RET=$(echo $CURL_RET | grep 'HTTP/1.1 200 OK')
if [ -n "$STATUS_RET" ]; then
CURRENT_FILE="$CHECK_FILE"
FOUND=TRUE
break
fi
done
if [ ! "$FOUND" = "TRUE" ]; then
CURRENT_STATUS="NA"
else
if [ -z "$CURRENT_HASH" ]; then
CURRENT_STATUS="OK"
else
if [ ! "$CHECK_HASH" = "yes" ]; then
CURRENT_STATUS="OK"
else
DOWNLOAD_FILE=$DOWNLOAD_FROM/$CHECK_FILE
HASH=$($CURL_CMD --silent $DOWNLOAD_FILE 2>/dev/null | sha256sum -b | cut -d" " -f1)
if [ "$CURRENT_HASH" = "$HASH" ]; then
CURRENT_STATUS="OK"
else
CURRENT_STATUS="CR"
fi
fi
fi
fi
fi
case "$CURRENT_NAME" in
domino|traveler|volt)
if [ -z "$CURRENT_PARTNO" ]; then
CURRENT_DOWNLOAD_URL="$DOWNLOAD_LINK_FLEXNET$DOWNLOAD_1ST_FILE$DOWNLOAD_LINK_FLEXNET_OPTIONS"
elif [ "$CURRENT_PARTNO" = "-" ]; then
CURRENT_DOWNLOAD_URL="$DOWNLOAD_LINK_FLEXNET$DOWNLOAD_1ST_FILE$DOWNLOAD_LINK_FLEXNET_OPTIONS"
else
CURRENT_DOWNLOAD_URL="$DOWNLOAD_LINK_FLEXNET$DOWNLOAD_1ST_FILE$DOWNLOAD_LINK_FLEXNET_OPTIONS"
fi
;;
startscript)
STARTSCRIPT_FILE=domino-startscript_v${CURRENT_VER}.taz
CURRENT_DOWNLOAD_URL=${STARTSCRIPT_GIT_URL}/releases/download/v${CURRENT_VER}/domino-startscript_v${CURRENT_VER}.taz
;;
*)
CURRENT_DOWNLOAD_URL=""
;;
esac
count=$(echo $CURRENT_VER | wc -c)
while [[ $count -lt 20 ]] ;
do
CURRENT_VER="$CURRENT_VER "
count=$((count+1));
done;
echo "$CURRENT_VER [$CURRENT_STATUS] $DOWNLOAD_1ST_FILE"
if [ ! -z "$DOWNLOAD_URLS_SHOW" ]; then
echo $CURRENT_DOWNLOAD_URL
elif [ ! "$CURRENT_STATUS" = "OK" ]; then
echo $CURRENT_DOWNLOAD_URL
echo
DOWNLOAD_ERROR_COUNT=$((DOWNLOAD_ERROR_COUNT+1))
fi
return 0
}
check_software_file()
{
FOUND=""
if [ -z "$PROD_NAME" ]; then
echo
echo "--- $1 ---"
echo
fi
if [ -z "$2" ]; then
SEARCH_STR="^$1|"
else
SEARCH_STR="^$1|$2|"
fi
if [ -z "$DOWNLOAD_SOFTWARE_FILE" ]; then
while read LINE
do
check_software $LINE
FOUND="TRUE"
done < <(grep "$SEARCH_STR" $SOFTWARE_FILE)
else
while read LINE
do
check_software $LINE
FOUND="TRUE"
done < <($CURL_CMD --silent $DOWNLOAD_SOFTWARE_FILE | grep "$SEARCH_STR")
fi
if [ -z "$PROD_NAME" ]; then
echo
else
if [ ! "$FOUND" = "TRUE" ]; then
CURRENT_VER=$2
count=$(echo $CURRENT_VER | wc -c)
while [[ $count -lt 20 ]] ;
do
CURRENT_VER="$CURRENT_VER "
count=$((count+1));
done;
echo "$CURRENT_VER [NA] Not found in software file!"
DOWNLOAD_ERROR_COUNT=$((DOWNLOAD_ERROR_COUNT+1))
fi
fi
}
check_software_status()
{
if [ ! -z "$DOWNLOAD_FROM" ]; then
DOWNLOAD_FILE=$DOWNLOAD_FROM/$SOFTWARE_FILE_NAME
CURL_RET=$($CURL_CMD "$DOWNLOAD_FILE" --silent --head 2>&1)
STATUS_RET=$(echo $CURL_RET | grep 'HTTP/1.1 200 OK')
if [ -n "$STATUS_RET" ]; then
DOWNLOAD_SOFTWARE_FILE=$DOWNLOAD_FILE
echo "Checking software via [$DOWNLOAD_SOFTWARE_FILE]"
fi
else
if [ ! -r "$SOFTWARE_FILE" ]; then
echo "Software [$SOFTWARE_FILE] Not found!"
DOWNLOAD_ERROR_COUNT=99
return 1
else
echo "Checking software via [$SOFTWARE_FILE]"
fi
fi
if [ -z "$PROD_NAME" ]; then
check_software_file "domino"
check_software_file "traveler"
check_software_file "volt"
if [ -n "$VERSE_VERSION" ]; then
check_software_file "verse" "$VERSE_VERSION"
fi
if [ -n "$CAPI_VERSION" ]; then
check_software_file "capi" "$CAPI_VERSION"
fi
if [ -n "$STARTSCRIPT_VER" ]; then
check_software_file "startscript" "$STARTSCRIPT_VER"
fi
else
echo
if [ -z "$PROD_VER" ]; then
check_software_file "$PROD_NAME"
else
check_software_file "$PROD_NAME" "$PROD_VER"
if [ ! -z "$PROD_FP" ]; then
check_software_file "$PROD_NAME" "$PROD_VER$PROD_FP"
fi
if [ ! -z "$PROD_HF" ]; then
check_software_file "$PROD_NAME" "$PROD_VER$PROD_FP$PROD_HF"
fi
fi
if [ -n "$VERSE_VERSION" ]; then
check_software_file "verse" "$VERSE_VERSION"
fi
if [ -n "$CAPI_VERSION" ]; then
check_software_file "capi" "$CAPI_VERSION"
fi
if [ -n "$STARTSCRIPT_VER" ]; then
check_software_file "startscript" "$STARTSCRIPT_VER"
fi
echo
fi
}
check_all_software()
{
SOFTWARE_FILE=$SOFTWARE_DIR/software.txt
# if software file isn't found check standard location (check might lead to the same directory if standard location already)
if [ ! -e "$SOFTWARE_FILE" ]; then