annotate prod/install-ipdp.sh @ 608:5cb80996e4d5

fix name of ipdp install, add backup/restore/update scripts
author Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
date Tue, 01 Jul 2025 21:00:04 +0100
parents 2aebef3e31bf
children
rev   line source
606
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
1 #!/bin/bash
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
2 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
3 # Copyright (c) 2025. Ohio Department of Education. - All Rights Reserved.
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
4 # Unauthorized copying of this file, in any medium, is strictly prohibited.
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
5 # Written by the State Software Development Team (http://ssdt.oecn.k12.oh.us/)
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
6 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
7 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
8
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
9 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
10 # read required env variables
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
11 BASEDIR="$PWD"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
12 source $BASEDIR/.env/ipdp-shared.properties
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
13 source $BASEDIR/.env/ipdp-app.properties
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
14 # docker login
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
15 echo "Attempting to login to $artifactUrl"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
16 docker login $artifactUrl -u $artifactUser -p $artifactPassword
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
17 # docker pull db image
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
18 echo "Attempting to pull $artifactUrl/ipdp-app:$appVersion"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
19 docker pull $artifactUrl/ipdp-app:$appVersion
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
20 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
21 # Builder docker run command based on settings in env files
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
22 echo "Building docker run command"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
23 dockerRunCommand="docker run --name $entityId-ipdp-app
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
24 --restart=unlipdp-stopped
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
25 --network $entityId-ipdp-net
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
26 -e SPRING_DATASOURCE_URL=jdbc:postgresql://$entityId-ipdp-db:5432/ipdpdb
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
27 -e SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
28 -e SPRING_DATASOURCE_USERNAME=postgres
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
29 -e SPRING_DATASOURCE_PASSWORD=$dbPassword
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
30 -e SPRING_PROFILES_ACTIVE=prod
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
31 -e APPLICATION_ADMIN_PASSWORD=$adminPassword
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
32 -e APPLICATION_ADMIN_RESET=$resetAdminPassword
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
33 -e USPS_CONFIGURATION_HOST=$uspsHost
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
34 -e USPS_CONFIGURATION_PORT=$uspsPort
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
35 -e USPS_CONFIGURATION_APIKEY=$uspsApiKey
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
36 -e USPS_CONFIGURATION_REMOTEAPIKEY=$uspsRemoteApiKey
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
37 -e USPS_CONFIGURATION_CONTEXT=$uspsContext
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
38 -e JAVA_OPTS=$java_opts"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
39 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
40 if [ ! -z "$virtualHost" ]; then
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
41 dockerRunCommand="$dockerRunCommand -e VIRTUAL_HOST=$virtualHost"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
42 fi
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
43 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
44 if [ ! -z "$virtualPort" ]; then
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
45 dockerRunCommand="$dockerRunCommand -e VIRTUAL_PORT=$virtualPort"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
46 fi
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
47 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
48 if [ ! -z "$letsencryptHost" ]; then
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
49 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_HOST=$letsencryptHost"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
50 fi
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
51 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
52 if [ ! -z "$letsencryptEmail" ]; then
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
53 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_EMAIL=$letsencryptEmail"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
54 fi
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
55 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
56 if [ ! -z "$hostPort" ]; then
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
57 dockerRunCommand="$dockerRunCommand -p $hostPort"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
58 fi
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
59 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
60 dockerRunCommand="$dockerRunCommand -d $artifactUrl/ipdp-app:$appVersion"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
61 #
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
62 # Execute constructed docker run command to create $entityId-ipdp-app container connected to db and docker network
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
63 echo "Executing docker run command"
2aebef3e31bf add ipdp install scripts
Justin Kleinknecht <justin.kleinknecht@mcoecn.org>
parents:
diff changeset
64 $dockerRunCommand