-
Notifications
You must be signed in to change notification settings - Fork 57
/
build.sh
executable file
·3659 lines (2878 loc) · 87.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, 2024 - APACHE 2.0 see LICENSE
# Copyright IBM Corporation 2015, 2020 - APACHE 2.0 see LICENSE
############################################################################
# Version 2.3.4 14.11.2024
# 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=$(readlink -f $0)
SCRIPT_DIR=$(dirname $SCRIPT_NAME)
# Standard configuration overwritten by build.cfg
# (Default) NGINX is used hosting software from the local "software" directory.
# Default: Update Linux base image while building the image
if [ -z "LinuxYumUpdate" ]; then
LinuxYumUpdate=yes
fi
# Default: Check if software exits
CHECK_SOFTWARE=yes
CONTAINER_BUILD_SCRIPT_VERSION=2.3.4
# OnTime version
SELECT_ONTIME_VERSION=1.11.1
# Build kit shortens the output. This isn't really helpful for troubleshooting and following the build process ...
export BUILDKIT_PROGRESS=plain
if [ "$1" == "--version" ]; then
echo $CONTAINER_BUILD_SCRIPT_VERSION
exit 0
fi
# ----------------------------------------
log_error_exit()
{
echo
echo $@
echo
exit 1
}
log()
{
echo
echo $@
echo
}
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
case "$LARCH" in
Linux|Darwin)
DOCKER_TZ=$(readlink /etc/localtime | awk -F'/zoneinfo/' '{print $2}')
;;
*)
DOCKER_TZ=""
;;
esac
echo "Using OS Timezone : [$DOCKER_TZ]"
else
if [ -e "/usr/share/zoneinfo/$DOCKER_TZ" ]; then
echo "Timezone configured: [$DOCKER_TZ]"
else
log_error_exit "Invalid timezone specified [$DOCKER_TZ]"
fi
fi
echo
return 0
}
detect_container_environment()
{
if [ -n "$CONTAINER_CMD" ]; then
return 0
fi
if [ -n "$USE_DOCKER" ]; then
CONTAINER_CMD=docker
return 0
fi
CONTAINER_RUNTIME_VERSION_STR=$(podman -v 2> /dev/null | head -1)
if [ -n "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_CMD=podman
return 0
fi
CONTAINER_RUNTIME_VERSION_STR=$(nerdctl -v 2> /dev/null | head -1)
if [ -n "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_CMD=nerdctl
return 0
fi
CONTAINER_RUNTIME_VERSION_STR=$(docker -v 2> /dev/null | head -1)
if [ -n "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_CMD=docker
return 0
fi
if [ -z "$CONTAINER_CMD" ]; then
log "No container environment detected!"
exit 1
fi
return 0
}
check_container_environment()
{
DOCKER_MINIMUM_VERSION="20.10.0"
PODMAN_MINIMUM_VERSION="3.3.0"
CONTAINER_ENV_NAME=
CONTAINER_RUNTIME_VERSION=
# No container environment required for native installs
if [ "$INSTALL_DOMINO_NATIVE" = "yes" ]; then
CONTAINER_CMD=NATIVE-INSTALL
return 0
fi
detect_container_environment
if [ "$CONTAINER_CMD" = "docker" ]; then
CONTAINER_ENV_NAME=docker
if [ -z "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_RUNTIME_VERSION_STR=$(docker -v 2> /dev/null | head -1)
fi
CONTAINER_RUNTIME_VERSION=$(echo $CONTAINER_RUNTIME_VERSION_STR | awk -F'version ' '{print $2 }'|cut -d"," -f1)
# Check container environment
check_version "$CONTAINER_RUNTIME_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" = "yes" ]; then
CONTAINER_CMD="sudo $CONTAINER_CMD"
fi
fi
fi
fi
if [ "$CONTAINER_CMD" = "podman" ]; then
check_version "$CONTAINER_RUNTIME_VERSION" "$PODMAN_MINIMUM_VERSION" "$CONTAINER_CMD"
CONTAINER_ENV_NAME=podman
if [ -z "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_RUNTIME_VERSION_STR=$(podman -v 2> /dev/null | head -1)
fi
CONTAINER_RUNTIME_VERSION=$(echo $CONTAINER_RUNTIME_VERSION_STR | awk -F'version ' '{print $2 }')
fi
if [ "$CONTAINER_CMD" = "nerdctl" ]; then
CONTAINER_ENV_NAME=nerdctl
if [ -z "$CONTAINER_RUNTIME_VERSION_STR" ]; then
CONTAINER_RUNTIME_VERSION_STR=$(nerdctl -v 2> /dev/null | head -1)
fi
CONTAINER_RUNTIME_VERSION=$(echo $CONTAINER_RUNTIME_VERSION_STR | awk -F'version ' '{print $2 }')
if [ -z "$CONTAINER_NAMESPACE" ]; then
CONTAINER_NAMESPACE=k8s.io
fi
# Always add namespace option to nerdctl command line
CONTAINER_CMD="$CONTAINER_CMD --namespace=$CONTAINER_NAMESPACE"
# nerdctl does not support a network name during build
else
if [ -n "$DOCKER_NETWORK_NAME" ]; then
CONTAINER_NETWORK_CMD="--network=$DOCKER_NETWORK_NAME"
fi
fi
return 0
}
show_version ()
{
echo
echo HCL Domino Container Build Script
echo ---------------------------------
echo "Version $CONTAINER_BUILD_SCRIPT_VERSION"
echo "(Running on $CONTAINER_ENV_NAME Version $CONTAINER_RUNTIME_VERSION)"
echo
return 0
}
usage()
{
# check container environment first
check_container_environment
echo
show_version
echo
echo "Usage: $(basename $SCRIPT_NAME) { domino | safelinx } 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 "-autotest test image after build"
echo "testimage=<img> test specified image"
echo "-scan scans a container image with Trivy for known vulnerabilities (CVEs)"
echo "-scan=<file> scans a container with Trivy and writes the result to a file"
echo " file names ending with .json result in a JSON formatted file (CVE count is written to console)"
echo "menu invokes the build menu. the build menu is also invoked when no option is specified"
echo "-menu=<file> uses the specified menu name. Default is no menu file is specfied: default.conf"
echo
echo Options
echo
echo "-conf uses the default.conf file to build an image (see menu for details)"
echo "-conf=<file> uses the specified file to build an image"
echo "-from=<image> builds from a specified build image. there are named images like 'ubi' predefined"
echo "-imagename=<img> defines the target image name"
echo "-imagetag=<img> defines the target image tag"
echo "-save=<img> exports the image after build. e.g. -save=domino-container.tgz"
echo "-tz=<timezone> explictly set container timezone during build. by default Linux TZ is used"
echo "-locale=<locale> specify Linux locale to install (e.g. de_DE.UTF-8)"
echo "-lang=<lang> specify Linux glibc language pack to install (e.g. de,it,fr). Multiple languages separated by comma"
echo "-pull always try to pull a newer base image version"
echo "-openssl adds OpenSSL to Domino image"
echo "-ssh adds OpenSSL client to Domino image (-borg option always includes SSH client)"
echo "-borg adds borg client and Domino Borg Backup integration to image"
echo "-verse adds Verse to a Domino image"
echo "-nomad adds the Nomad server to a Domino image"
echo "-traveler adds the Traveler server to a Domino image"
echo "-leap adds the Domino Leap to a Domino image"
echo "-capi adds the C-API sdk/toolkit to a Domino image"
echo "-domlp=xx adds the specified Language Pack to the image"
echo "-restapi adds the Domino REST API to the image"
echo "-ontime adds OnTime from Domino V14 web-kit to the image"
echo "-tika updates the Tika server to the Domino server"
echo "-node_exporter Installs Prometheus node_exporter into the container"
echo "-k8s-runas adds K8s runas user support"
echo "-linuxpkg=<pkg> add on or more Linux packages to the container image. Multiple pgks are separated by blank and require quotes"
echo "-startscript=x installs specified start script version from software repository"
echo "-custom-addon=x specify a tar file with additional Domino add-on sofware to install format: (https://)file.taz#sha256checksum"
echo "-software=<dir> explicitly specify SOFTWARE_DIR and override cfg file "
echo
echo SafeLinx options
echo
echo "-nomadweb adds the latest Nomad Web version to a SafeLinx image"
echo "-mysql adds the MySQL client to the SafeLinx image"
echo "-mssql adds the Mircosoft SQL Server client to the SafeLinx image"
echo
echo "Special commands:"
echo
echo "save <img> <my.tgz> exports the specified image to tgz format (e.g. save hclcom/domino:latest domino.tgz)"
echo
echo "Examples:"
echo
echo " $(basename $SCRIPT_NAME) domino1 14.0 fp2"
echo " $(basename $SCRIPT_NAME) traveler 14.0 fp1"
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] $CONTAINER_RUNTIME_VERSION"
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 "DOMLP_VER : [$DOMLP_VER]"
echo "DOMRESTAPI_VER : [$DOMRESTAPI_VER]"
echo "PROD_DOWNLOAD_FILE : [$PROD_DOWNLOAD_FILE]"
echo "PROD_FP_DOWNLOAD_FILE: [$PROD_FP_DOWNLOAD_FILE]"
echo "PROD_HF_DOWNLOAD_FILE: [$PROD_HF_DOWNLOAD_FILE]"
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 "NOMAD_VERSION : [$NOMAD_VERSION]"
echo "TRAVELER_VERSION : [$TRAVELER_VERSION]"
echo "LEAP_VERSION : [$LEAP_VERSION]"
echo "CAPI_VERSION : [$CAPI_VERSION]"
echo "NOMADWEB_VERSION : [$NOMADWEB_VERSION]"
echo "MYSQL_INSTALL : [$MYSQL_INSTALL]"
echo "MSSQL_INSTALL : [$MSSQL_INSTALL]"
echo "BORG_INSTALL : [$BORG_INSTALL]"
echo "TIKA_INSTALL : [$TIKA_INSTALL]"
echo "NODE_EXPORTER_INSTALL: [$NODE_EXPORTER_INSTALL]"
echo "LINUX_PKG_ADD : [$LINUX_PKG_ADD]"
echo "STARTSCRIPT_VER : [$STARTSCRIPT_VER]"
echo "CUSTOM_ADD_ONS : [$CUSTOM_ADD_ONS]"
echo "EXPOSED_PORTS : [$EXPOSED_PORTS]"
echo "LinuxYumUpdate : [$LinuxYumUpdate]"
echo "DOMINO_LANG : [$DOMINO_LANG]"
echo "LINUX_LANG : [$LINUX_LANG]"
echo "DOCKER_TZ : [$DOCKER_TZ]"
echo "NAMESPACE : [$CONTAINER_NAMESPACE]"
echo "K8S_RUNAS_USER : [$K8S_RUNAS_USER_SUPPORT]"
echo "SPECIAL_CURL_ARGS : [$SPECIAL_CURL_ARGS]"
echo "DominoResponseFile : [$DominoResponseFile]"
echo "BUILD_SCRIPT_OPTIONS : [$BUILD_SCRIPT_OPTIONS]"
echo
return 0
}
check_build_nginx_image()
{
if [ -z "$NGINX_IMAGE_NAME" ]; then
return 0
fi
local IMAGE_ID="$($CONTAINER_CMD inspect --format "{{.ID}}" $NGINX_IMAGE_NAME 2>/dev/null)"
if [ -n "$IMAGE_ID" ]; then
# Image already exists
log "Info: $NGINX_IMAGE_NAME already exists"
sleep 1
return 0
fi
header "Building NGINX Image $NGINX_IMAGE_NAME ..."
if [ -z "$NGINX_BASE_IMAGE" ]; then
NGINX_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
fi
# Get Build Time
BUILDTIME=$(date +"%d.%m.%Y %H:%M:%S")
# Switch to directory containing the dockerfiles
cd dockerfiles
export BUILDAH_FORMAT
$CONTAINER_CMD build --no-cache $BUILD_OPTIONS $DOCKER_PULL_OPTION -f dockerfile_nginx -t $NGINX_IMAGE_NAME --build-arg NGINX_BASE_IMAGE=$NGINX_BASE_IMAGE .
cd ..
}
build_squid_image()
{
if [ -z "$SQUID_IMAGE_NAME" ]; then
return 0
fi
check_timezone
check_container_environment
header "Building Squid Image $SQUID_IMAGE_NAME ..."
if [ -z "$SQUID_BASE_IMAGE" ]; then
SQUID_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
fi
# Get Build Time
BUILDTIME=$(date +"%d.%m.%Y %H:%M:%S")
# Switch to directory containing the dockerfiles
cd dockerfiles
export BUILDAH_FORMAT
$CONTAINER_CMD build --no-cache $BUILD_OPTIONS $DOCKER_PULL_OPTION -f dockerfile_squid -t $SQUID_IMAGE_NAME --build-arg SQUID_BASE_IMAGE=$SQUID_BASE_IMAGE .
cd ..
}
nginx_start()
{
if [ "$INSTALL_DOMINO_NATIVE" = "yes" ]; then
return 0
fi
# Create a nginx container hosting software download locally
local IMAGE_NAME=docker.io/library/nginx:latest
if [ -n "$NGINX_IMAGE_NAME" ]; then
check_build_nginx_image
IMAGE_NAME=$NGINX_IMAGE_NAME
elif [ -n "$NGINX_IMAGE" ]; then
IMAGE_NAME=$NGINX_IMAGE
fi
# 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] based on [$IMAGE_NAME]"
$CONTAINER_CMD run --name $SOFTWARE_CONTAINER -p $SOFTWARE_PORT:80 -v $SOFTWARE_DIR:/usr/share/nginx/html:Z -d $IMAGE_NAME
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
# Ignore proxy for local repo IP
if [ -n "$SOFTWARE_REPO_IP" ]; then
if [ -z "$SPECIAL_CURL_ARGS" ]; then
SPECIAL_CURL_ARGS="--noproxy $SOFTWARE_REPO_IP"
else
SPECIAL_CURL_ARGS="$SPECIAL_CURL_ARGS --noproxy $SOFTWARE_REPO_IP"
fi
fi
DOWNLOAD_FROM=http://$SOFTWARE_REPO_IP
echo "Hosting HCL Software repository on $DOWNLOAD_FROM"
echo
}
nginx_stop()
{
if [ "$INSTALL_DOMINO_NATIVE" = "yes" ]; then
return 0
fi
# 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
echo
}
http_head_check()
{
local CURL_RET=$($CURL_CMD -w 'RESP_CODE:%{response_code}\n' --silent --head "$1" | grep 'RESP_CODE:200')
if [ -z "$CURL_RET" ]; then
return 0
else
return 1
fi
}
get_current_version()
{
if [ -n "$DOWNLOAD_FROM" ]; then
DOWNLOAD_FILE=$DOWNLOAD_FROM/$VERSION_FILE_NAME
http_head_check "$DOWNLOAD_FILE"
if [ "$?" = "1" ]; then
DOWNLOAD_VERSION_FILE=$DOWNLOAD_FILE
fi
fi
if [ -n "$DOWNLOAD_VERSION_FILE" ]; then
LINE=$($CURL_CMD --silent $DOWNLOAD_VERSION_FILE | grep "^$1|")
else
if [ ! -r "$VERSION_FILE" ]; then
echo "No current version file found! [$VERSION_FILE]"
else
LINE=$(grep "^$1|" $VERSION_FILE)
fi
fi
if [ -z "$2" ]; then
PROD_VER=$(echo $LINE|cut -d'|' -f2)
PROD_FP=$(echo $LINE|cut -d'|' -f3)
PROD_HF=$(echo $LINE|cut -d'|' -f4)
else
export $2=$(echo $LINE|cut -d'|' -f2)$(echo $LINE|cut -d'|' -f3)$(echo $LINE|cut -d'|' -f4)
fi
return 0
}
get_current_addon_version()
{
local S1=$2
local S2=${!2}
if [ -n "$DOWNLOAD_FROM" ]; then
DOWNLOAD_FILE=$DOWNLOAD_FROM/$VERSION_FILE_NAME
http_head_check "$DOWNLOAD_FILE"
if [ "$?" = "1" ]; then
DOWNLOAD_VERSION_FILE=$DOWNLOAD_FILE
fi
fi
if [ -n "$DOWNLOAD_VERSION_FILE" ]; then
LINE=$($CURL_CMD --silent $DOWNLOAD_VERSION_FILE | grep "^$1|")
else
if [ ! -r "$VERSION_FILE" ]; then
echo "No current version file found! [$VERSION_FILE]"
else
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 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
FROM_IMAGE=ubi9-minimal
elif [ "$PROD_NAME" = "traveler" ]; then
FROM_IMAGE=hclcom/domino:latest
elif [ "$PROD_NAME" = "leap" ]; then
FROM_IMAGE=hclcom/domino:latest
elif [ "$PROD_NAME" = "safelinx" ]; then
FROM_IMAGE=ubi9-minimal
else
FROM_IMAGE=ubi9-minimal
fi
fi
case "$FROM_IMAGE" in
centos8)
LINUX_NAME="CentOS Stream 8"
BASE_IMAGE=quay.io/centos/centos:stream8
;;
centos|centos9)
LINUX_NAME="CentOS Stream 9"
BASE_IMAGE=quay.io/centos/centos:stream9
;;
rocky)
LINUX_NAME="Rocky Linux 9"
BASE_IMAGE=docker.io/rockylinux/rockylinux:9
;;
rocky8)
LINUX_NAME="Rocky Linux 8"
BASE_IMAGE=docker.io/rockylinux/rockylinux:8
;;
alma)
LINUX_NAME="Alma Linux 9"
BASE_IMAGE=almalinux:9
;;
alma8)
LINUX_NAME="Alma Linux 8"
BASE_IMAGE=almalinux:8
;;
amazon)
LINUX_NAME="Amazon Linux"
BASE_IMAGE=docker.io/amazonlinux
;;
oracle)
LINUX_NAME="Oracle Linux 9"
BASE_IMAGE=oraclelinux:9
;;
photon)
LINUX_NAME="VMware Photon OS 5"
BASE_IMAGE=docker.io/photon:5.0
;;
photon5)
LINUX_NAME="VMware Photon OS 5"
BASE_IMAGE=docker.io/photon:5.0
;;
ubi)
LINUX_NAME="RedHat UBI 9"
BASE_IMAGE=registry.access.redhat.com/ubi9
;;
ubi8)
LINUX_NAME="RedHat UBI 8"
BASE_IMAGE=registry.access.redhat.com/ubi8
;;
ubi9)
LINUX_NAME="RedHat UBI 9"
BASE_IMAGE=registry.access.redhat.com/ubi9
;;
ubi-minimal)
LINUX_NAME="RedHat UBI 9 minimal"
BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal
;;
ubi9-minimal)
LINUX_NAME="RedHat UBI 9 minimal"
BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal
;;
ubuntu)
LINUX_NAME="Ubuntu 24.04 LTS"
BASE_IMAGE=ubuntu
;;
ubuntu22)
LINUX_NAME="Ubuntu 22.04 LTS"
BASE_IMAGE=ubuntu:jammy
;;
leap)
LINUX_NAME="SUSE Leap"
BASE_IMAGE=opensuse/leap
;;
leap15.6)
LINUX_NAME="SUSE Leap 15.6"
BASE_IMAGE=opensuse/leap:15.6
;;
bci)
LINUX_NAME="SUSE Enterprise"
BASE_IMAGE=registry.suse.com/bci/bci-base
;;
bci15.6)
LINUX_NAME="SUSE Enterprise 15.6"
BASE_IMAGE=registry.suse.com/bci/bci-base:15.6
;;
archlinux)
LINUX_NAME="Arch Linux (experimental)"
BASE_IMAGE=docker.io/archlinux
;;
kali)
LINUX_NAME="Kali Linux (experimental)"
BASE_IMAGE=docker.io/kalilinux/kali-rolling
;;
*)
LINUX_NAME="Manual specified base image"
BASE_IMAGE=$FROM_IMAGE
echo "Info: Manual specified base image used! [$FROM_IMAGE]"
;;
esac
echo "Base Image - $LINUX_NAME"
}
set_standard_image_labels()
{
if [ -z "$CONTAINER_MAINTAINER" ]; then
CONTAINER_MAINTAINER="thomas.hampel, daniel.nashed@nashcom.de"
fi
if [ -z "$CONTAINER_VENDOR" ]; then
CONTAINER_VENDOR="Domino Container Community Project"
fi
if [ -z "$CONTAINER_DOMINO_NAME" ]; then
CONTAINER_DOMINO_NAME="HCL Domino Community Image"
fi
if [ -z "$CONTAINER_DOMINO_DESCRIPTION" ]; then
CONTAINER_DOMINO_DESCRIPTION="HCL Domino Enterprise Server"
fi
if [ -z "$CONTAINER_TRAVELER_NAME" ]; then
CONTAINER_TRAVELER_NAME="HCL Traveler Community Image"
fi
if [ -z "$CONTAINER_TRAVELER_DESCRIPTION" ]; then
CONTAINER_TRAVELER_DESCRIPTION="HCL Traveler Mobile Sync Server"
fi
if [ -z "$CONTAINER_VOLT_NAME" ]; then
CONTAINER_VOLT_NAME="HCL Volt Community Image"
fi
if [ -z "$CONTAINER_VOLT_DESCRIPTION" ]; then
CONTAINER_VOLT_DESCRIPTION="HCL Volt - Low Code platform"
fi
if [ -z "$CONTAINER_LEAP_NAME" ]; then
CONTAINER_LEAP_NAME="HCL Domino Leap Community Image"
fi
if [ -z "$CONTAINER_LEAP_DESCRIPTION" ]; then
CONTAINER_LEAP_DESCRIPTION="HCL Domino Leap - Low Code platform"
fi
if [ -z "$CONTAINER_SAFELINX_NAME" ]; then
CONTAINER_SAFELINX_NAME="HCL SafeLinx Community Image"
fi
if [ -z "$CONTAINER_SAFELINX_DESCRIPTION" ]; then
CONTAINER_SAFELINX_DESCRIPTION="HCL SafeLinx - Secure reverse proxy & VPN"
fi
if [ -z "$CONTAINER_OPENSHIFT_EXPOSED_SERVICES" ]; then
CONTAINER_OPENSHIFT_EXPOSED_SERVICES="1352:nrpc 80:http 110:pop3 143:imap 389:ldap 443:https 636:ldaps 993:imaps 995:pop3s"
fi
if [ -z "$CONTAINER_OPENSHIFT_MIN_MEMORY" ]; then
CONTAINER_OPENSHIFT_MIN_MEMORY="2Gi"
fi
if [ -z "$CONTAINER_OPENSHIFT_MIN_CPU" ]; then
CONTAINER_OPENSHIFT_MIN_CPU=2
fi
}
check_exposed_ports()
{
# Allow custom exposed ports
if [ -n "$EXPOSED_PORTS" ]; then
return 0
fi
EXPOSED_PORTS="1352 25 80 110 143 389 443 636 993 995 63148 63149"
if [ -n "$NOMAD_VERSION" ]; then
EXPOSED_PORTS="$EXPOSED_PORTS 9443"
fi
if [ -n "$NODE_EXPORTER_INSTAL" ]; then
EXPOSED_PORTS="$EXPOSED_PORTS 9100"
fi
return 0
}
add_custom_addon_label()
{
local ADDON_NAME=
local ADDON_VER=
local ADDON_TEXT=
if [ -z "$1" ]; then
return 0
fi
ADDON_NAME="$(basename $(echo $1| cut -f1 -d# | cut -f1 -d'.'))"
ADDON_VER="$(echo $1| cut -f3 -d#)"
if [ -z "$ADDON_VER" ]; then
ADDON_TEXT="$ADDON_NAME"
else
ADDON_TEXT="$ADDON_NAME=$ADDON_VER"
fi
if [ -z "$CONTAINER_DOMINO_CUSTOM_ADDONS" ]; then
CONTAINER_DOMINO_CUSTOM_ADDONS="$ADDON_TEXT"
else
CONTAINER_DOMINO_CUSTOM_ADDONS="$CONTAINER_DOMINO_CUSTOM_ADDONS,$ADDON_TEXT"
fi
}
check_custom_addon_label()
{
if [ -z "$CUSTOM_ADD_ONS" ]; then
return 0
fi
local CUSTOM_INSTALL_FILE=
for CUSTOM_INSTALL_FILE in $(echo "$CUSTOM_ADD_ONS" | tr "," "\n" ) ; do
add_custom_addon_label "$CUSTOM_INSTALL_FILE"
done
}
add_addon_label()
{
if [ -z "$1" ]; then
return 0
fi
if [ -z "$2" ]; then
return 0
fi
if [ -z "$CONTAINER_DOMINO_ADDONS" ]; then
CONTAINER_DOMINO_ADDONS="$1=$2"
else
CONTAINER_DOMINO_ADDONS="$CONTAINER_DOMINO_ADDONS,$1=$2"
fi
}
check_addon_label()
{
if [ "$DOCKER_FILE" = "dockerfile_hcl" ] || [ "$DominoResponseFile" = "domino14_full_install.properties" ]; then
# HCL container image build and full installer file: Verse, Nomad, OnTime
if [ -z "$VERSE_VERSION" ]; then
add_addon_label "verse" "3.1.0"
fi
if [ -z "$NOMAD_VERSION" ]; then
add_addon_label "nomad" "1.0.9"
fi
add_addon_label "ontime" "11.1.1"
elif [ "$DominoResponseFile" = "domino14_ontime_install.properties" ]; then
# OnTime is added from Domino V14 WebKit
add_addon_label "ontime" "11.1.1"
fi
if [ -n "$DOMLP_LANG" ]; then
add_addon_label "languagepack" "$DOMLP_LANG"
fi
if [ -n "$VERSE_VERSION" ]; then
add_addon_label "verse" "$VERSE_VERSION"
fi