comparison prod/install-itcm-app.sh @ 408:e49038cbb14c

Add scripts for ITC Management application
author Marc Davis <marc.davis@mcoecn.org>
date Mon, 10 Oct 2022 14:32:06 -0400
parents
children edf477197f1b
comparison
equal deleted inserted replaced
405:4e35cb59f86c 408:e49038cbb14c
1 #!/bin/bash
2 #
3 # read required env variables
4 BASEDIR="$PWD"
5 source $BASEDIR/.env/itcm-shared.properties
6 source $BASEDIR/.env/itcm-app.properties
7 # docker login
8 echo "Attempting to login to $artifactUrl"
9 docker login $artifactUrl -u $artifactUser -p $artifactPassword
10 # docker pull db image
11 echo "Attempting to pull $artifactUrl/itcm-app:$appVersion"
12 docker pull $artifactUrl/itcm-app:$appVersion
13 #
14 # Builder docker run command based on settings in env files
15 echo "Building docker run command"
16 dockerRunCommand="docker run --name $entityId-itcm-app
17 --restart=unless-stopped
18 --network $entityId-itcm-net
19 -e SPRING_DATASOURCE_URL=jdbc:postgresql://$entityId-itcm-db:5432/itcmdb
20 -e SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
21 -e SPRING_DATASOURCE_USERNAME=postgres
22 -e SPRING_DATASOURCE_PASSWORD=$dbPassword
23 -e SPRING_PROFILES_ACTIVE=prod
24 -e APPLICATION_ADMIN_PASSWORD=$adminPassword
25 -e APPLICATION_ADMIN_RESET=$resetAdminPassword
26 -e JAVA_OPTS=$java_opts"
27 #
28 if [ ! -z "$virtualHost" ]; then
29 dockerRunCommand="$dockerRunCommand -e VIRTUAL_HOST=$virtualHost"
30 fi
31 #
32 if [ ! -z "$virtualPort" ]; then
33 dockerRunCommand="$dockerRunCommand -e VIRTUAL_PORT=$virtualPort"
34 fi
35 #
36 if [ ! -z "$letsencryptHost" ]; then
37 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_HOST=$letsencryptHost"
38 fi
39 #
40 if [ ! -z "$letsencryptEmail" ]; then
41 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_EMAIL=$letsencryptEmail"
42 fi
43 #
44 if [ ! -z "$hostPort" ]; then
45 dockerRunCommand="$dockerRunCommand -p $hostPort"
46 fi
47 #
48 #
49 if [ ! -z "$duoEnabled" ]; then
50 echo "Adding Duo Configuration"
51 dockerRunCommand="$dockerRunCommand
52 -e SSDT_DUO_ENABLED=$duoEnabled
53 -e SSDT_DUO_CLIENT_ID=$duoClientId
54 -e SSDT_DUO_CLIENT_SECRET=$duoClientSecret
55 -e SSDT_DUO_API_HOSTNAME=$duoApiHostname
56 -e SSDT_DUO_FAIL_OPEN=$duoFailOpen
57 -e SSDT_DUO_ITCM_HOST=$duoItcmHost
58 -e SSDT_DUO_ITCM_PORT=$duoItcmPort
59 -e SSDT_DUO_ITCM_CONTEXT=$duoItcmContext
60 -e SSDT_DUO_MINUTES_UNTIL_EXPIRATION=$duoMinutesUntilExpiration"
61 fi
62 #
63 #
64 if [ ! -z "$ads_config1_enabled" ]; then
65 echo "Add Window Active Director Configuration 1"
66 dockerRunCommand="$dockerRunCommand
67 -e SSDT_ADS_CONFIG1_ENABLED=$ads_config1_enabled
68 -e SSDT_ADS_CONFIG1_DOMAIN=$ads_config1_domain
69 -e SSDT_ADS_CONFIG1_LDAP_URL=$ads_config1_ldap_url
70 -e SSDT_ADS_CONFIG1_ROOT_DN=$ads_config1_root_dn
71 -e SSDT_ADS_CONFIG1_SEARCH_FILTER=$ads_config1_search_filter"
72 fi
73 #
74 #
75 if [ ! -z "$ads_config2_enabled" ]; then
76 echo "Add Window Active Director Configuration 2"
77 dockerRunCommand="$dockerRunCommand
78 -e SSDT_ADS_CONFIG2_ENABLED=$ads_config2_enabled
79 -e SSDT_ADS_CONFIG2_DOMAIN=$ads_config2_domain
80 -e SSDT_ADS_CONFIG2_LDAP_URL=$ads_config2_ldap_url
81 -e SSDT_ADS_CONFIG2_ROOT_DN=$ads_config2_root_dn
82 -e SSDT_ADS_CONFIG2_SEARCH_FILTER=$ads_config2_search_filter"
83 fi
84 #
85 #
86 if [ ! -z "$ads_config3_enabled" ]; then
87 echo "Add Window Active Director Configuration 3"
88 dockerRunCommand="$dockerRunCommand
89 -e SSDT_ADS_CONFIG3_ENABLED=$ads_config3_enabled
90 -e SSDT_ADS_CONFIG3_DOMAIN=$ads_config3_domain
91 -e SSDT_ADS_CONFIG3_LDAP_URL=$ads_config3_ldap_url
92 -e SSDT_ADS_CONFIG3_ROOT_DN=$ads_config3_root_dn
93 -e SSDT_ADS_CONFIG3_SEARCH_FILTER=$ads_config3_search_filter"
94 fi
95 #
96 #
97 dockerRunCommand="$dockerRunCommand -d $artifactUrl/itcm-app:$appVersion"
98 #
99 # Execute constructed docker run command to create $entityId-itcm-app container connected to db and docker network
100 echo "Executing docker run command"
101 $dockerRunCommand