-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·99 lines (82 loc) · 1.97 KB
/
deploy.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
#!/bin/bash
#######################################################
# A script to deploy Dynamic Authenticator resources. #
#######################################################
export CONFIG_ENCRYPTION_KEY="02b891b3ec501cece86de216a6f6a15f585dddcbd56fe21b410233d78dfaa79e"
usage()
{
echo "A script to deploy Dynamic Authenticator Demo resources"
echo ""
echo "Usage: deploy.sh [ -a | --rebuild-api ] [ -c | --regenerate-certs ]"
exit 2
}
#
# Ensure that we are in the folder containing this script
#
cd "$(dirname "${BASH_SOURCE[0]}")"
if [ ! -f './git/hooks/pre-commit' ]; then
cp ./hooks/pre-commit ./.git/hooks/
fi
#
# First check prerequisites
#
if [ ! -f './idsvr/license.json' ]; then
echo "Please provide a license.json file in the idsvr folder in order to deploy the system."
exit 1
fi
#
# Parse the script options
#
REBUILD_API=0
REGENERATE_CERTS=0
while getopts "ca-:" option; do
case $option in
c) REGENERATE_CERTS=1
;;
a) REBUILD_API=1
;;
-)
case $OPTARG in
regenerate-certs) REGENERATE_CERTS=1
;;
rebuild-api) REBUILD_API=1
;;
*) usage
;;
esac
;;
*) usage
;;
esac
done
#
# Create certificates if needed
#
if [ ! -f './certs/example.ca.p12' ] || [ $REGENERATE_CERTS == 1 ]; then
echo "Creating certificates for idsvr instances."
./certs/create-certs.sh
if [ $? -ne 0 ]; then
echo "Problem encountered when creating certificates."
exit 1
fi
fi
#
# Spin up all containers, using the Docker Compose file.
#
echo "Deploying resources."
docker compose --project-name dynamic-auth down
if [ $REBUILD_API == 1 ]; then
docker compose --project-name dynamic-auth up --detach --build
else
docker compose --project-name dynamic-auth up --detach
fi
if [ $? -ne 0 ]; then
echo "Problem encountered starting Docker components"
exit 1
fi
echo "Uploading server certificates"
./certs/deploy-idsvr-certs.sh
if [ $? -ne 0 ]; then
echo "Problem encountered when uploading certificates"
exit 1
fi