annotate prod/update-inventory-app.sh @ 605:46a67e7afd98 release/2.23.0 tip

flow: Created branch 'release/2.23.0'.
author Marc Davis <marc.davis@mcoecn.org>
date Wed, 18 Sep 2024 20:38:06 -0400
parents f05817aee0f0
children
rev   line source
363
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
1 #!/bin/bash
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
2 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
3 # read required env variables
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
4 BASEDIR="$PWD"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
5 source $BASEDIR/.env/ssdt-inventory-shared.properties
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
6 source $BASEDIR/.env/ssdt-inventory-app.properties
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
7 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
8 # docker login
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
9 echo "Attempting to login to $artifactUrl"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
10 docker login $artifactUrl -u $artifactUser -p $artifactPassword
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
11 # docker pull app image
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
12 echo "Attempting to pull $artifactUrl/inventory-app:$appVersion"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
13 docker pull $artifactUrl/inventory-app:$appVersion
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
14 #
369
3dc92d4243ef DEP-21 Update update-inventory-app.sh script to also update inventory-importapp image
Matt Calmes <calmes@ssdt-ohio.org>
parents: 363
diff changeset
15 echo "Attempting to pull $artifactUrl/inventory-importapp:$appVersion"
3dc92d4243ef DEP-21 Update update-inventory-app.sh script to also update inventory-importapp image
Matt Calmes <calmes@ssdt-ohio.org>
parents: 363
diff changeset
16 docker pull $artifactUrl/inventory-importapp:$appVersion
3dc92d4243ef DEP-21 Update update-inventory-app.sh script to also update inventory-importapp image
Matt Calmes <calmes@ssdt-ohio.org>
parents: 363
diff changeset
17 #
363
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
18 # docker stop inventory app container
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
19 echo "Attempting to stop $entityId-inventory-app container"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
20 docker stop $entityId-inventory-app
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
21 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
22 # docker rm inventory app container
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
23 echo "Attempting to remove $entityId-inventory-app container"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
24 docker rm $entityId-inventory-app
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
25 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
26 # docker run inventory app container based on new image
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
27 dockerRunCommand="docker run --name $entityId-inventory-app --restart=unless-stopped --network $entityId-inventory-net -e SPRING_DATASOURCE_URL=jdbc:postgresql://$entityId-inventory-db:5432/invdb"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
28 dockerRunCommand="$dockerRunCommand -e SPRING_DATASOURCE_PASSWORD=$dbPassword -e SPRING_PROFILES_ACTIVE=prod -e APPLICATION_ADMIN_PASSWORD=$adminPassword -e JAVA_OPTS=$java_opts"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
29 dockerRunCommand="$dockerRunCommand -e USAS_CONFIGURATION_HOST=$usasHost -e USAS_CONFIGURATION_PORT=$usasPort -e USAS_CONFIGURATION_APIKEY=$inventoryApiKey -e USAS_CONFIGURATION_REMOTEAPIKEY=$usasApiKey"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
30 if [ ! -z "$virtualHost" ]; then
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
31 dockerRunCommand="$dockerRunCommand -e VIRTUAL_HOST=$virtualHost"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
32 fi
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
33 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
34 if [ ! -z "$virtualPort" ]; then
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
35 dockerRunCommand="$dockerRunCommand -e VIRTUAL_PORT=$virtualPort"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
36 fi
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
37 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
38 if [ ! -z "$letsencryptHost" ]; then
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
39 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_HOST=$letsencryptHost"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
40 fi
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
41 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
42 if [ ! -z "$letsencryptEmail" ]; then
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
43 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_EMAIL=$letsencryptEmail"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
44 fi
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
45 #
402
be08b5a62a77 INV-334: Updated inventory scripts to handle new reset property.
Jason Klinger <klinger@nwoca.org>
parents: 369
diff changeset
46 if [ ! -z "$applicationAdminReset" ]; then
be08b5a62a77 INV-334: Updated inventory scripts to handle new reset property.
Jason Klinger <klinger@nwoca.org>
parents: 369
diff changeset
47 dockerRunCommand="$dockerRunCommand -e APPLICATION_ADMIN_RESET=$applicationAdminReset"
be08b5a62a77 INV-334: Updated inventory scripts to handle new reset property.
Jason Klinger <klinger@nwoca.org>
parents: 369
diff changeset
48 fi
be08b5a62a77 INV-334: Updated inventory scripts to handle new reset property.
Jason Klinger <klinger@nwoca.org>
parents: 369
diff changeset
49 #
363
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
50 if [ ! -z "$hostPort" ]; then
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
51 dockerRunCommand="$dockerRunCommand -p $hostPort"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
52 fi
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
53 #
417
c3f58eddce4f INV-475: Added duo properties to inventory scripts.
Jason Klinger <klinger@nwoca.org>
parents: 402
diff changeset
54 if [ ! -z "$duo_enabled" ]; then
c3f58eddce4f INV-475: Added duo properties to inventory scripts.
Jason Klinger <klinger@nwoca.org>
parents: 402
diff changeset
55 dockerRunCommand="$dockerRunCommand -e DUO_ENABLED=$duo_enabled -e DUO_CLIENT_ID=$duo_client_id -e DUO_CLIENT_SECRET=$duo_client_secret -e DUO_API_HOSTNAME=$duo_api_hostname -e DUO_FAIL_OPEN=$duo_fail_open "
c3f58eddce4f INV-475: Added duo properties to inventory scripts.
Jason Klinger <klinger@nwoca.org>
parents: 402
diff changeset
56 dockerRunCommand="$dockerRunCommand -e DUO_USXS_HOST=$duo_usxs_host -e DUO_USXS_PORT=$duo_usxs_port -e DUO_USXS_CONTEXT=$duo_usxs_context -e DUO_MINUTES_UNTIL_EXPIRATION=$duo_minutes_until_expiration "
c3f58eddce4f INV-475: Added duo properties to inventory scripts.
Jason Klinger <klinger@nwoca.org>
parents: 402
diff changeset
57 fi
c3f58eddce4f INV-475: Added duo properties to inventory scripts.
Jason Klinger <klinger@nwoca.org>
parents: 402
diff changeset
58 #
604
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
59 #
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
60 if [ ! -z "$miniOrangeEnabled" ]; then
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
61 echo "Adding MiniOrange Configuration"
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
62 dockerRunCommand="$dockerRunCommand -e MINI_ORANGE_ENABLED=$miniOrangeEnabled -e MINI_ORANGE_CLIENT_ID=$miniOrangeClientId -e MINI_ORANGE_CLIENT_SECRET=$miniOrangeClientSecret -e MINI_ORANGE_API_HOSTNAME=$miniOrangeApiHostname "
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
63 dockerRunCommand="$dockerRunCommand -e MINI_ORANGE_FAIL_OPEN=$miniOrangeFailOpen -e MINI_ORANGE_APP_HOST=$miniOrangeEssHost -e MINI_ORANGE_MINUTES_UNTIL_EXPIRATION=$miniOrangeMinutesUntilExpiration "
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
64 fi
f05817aee0f0 Add mini orange envars
Marc Davis <marc.davis@mcoecn.org>
parents: 417
diff changeset
65 #
363
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
66 dockerRunCommand="$dockerRunCommand -d $artifactUrl/inventory-app:$appVersion"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
67 #
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
68 # Execute constructed docker run command to create $entityId-inventory-app container connected to db and docker network
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
69 echo "Executing docker run command"
cf7166c5c52f INV-196 Move inventory scripts to prod directory
Matt Calmes <calmes@ssdt-ohio.org>
parents:
diff changeset
70 $dockerRunCommand