blob: c41192fe2ce65f0b4d3716de14b7bc8b90669777 [file] [log] [blame]
Instrumental32cdd552018-07-19 13:29:32 -05001#!/bin/bash
2. ./d.props
3
Instrumentalab502672018-08-20 14:31:35 -05004function run_it() {
5 docker run $@ \
Instrumental32cdd552018-07-19 13:29:32 -05006 --mount 'type=volume,src=aaf_config,dst='$CONF_ROOT_DIR',volume-driver=local' \
7 --add-host="$HOSTNAME:$HOST_IP" \
8 --add-host="aaf.osaaf.org:$HOST_IP" \
9 --env AAF_ENV=${AAF_ENV} \
10 --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \
11 --env LATITUDE=${LATITUDE} \
12 --env LONGITUDE=${LONGITUDE} \
13 --name aaf_config_$USER \
Instrumentale44d2f72018-08-16 17:22:45 -050014 $PREFIX${ORG}/${PROJECT}/aaf_config:${VERSION} \
Instrumentalab502672018-08-20 14:31:35 -050015 /bin/bash $PARAMS
16}
17
18function encrypt_it() {
19 docker exec -t aaf_config_$USER /bin/bash /opt/app/aaf_config/bin/agent.sh NOOP encrypt "$1" "$2"
20}
21
Instrumentalb8a81292018-08-23 16:32:45 -050022function set_it() {
23 docker exec -t aaf_config_$USER /bin/bash /opt/app/aaf_config/bin/agent.sh NOOP setProp "$1" "$2"
24}
25
Instrumentalab502672018-08-20 14:31:35 -050026P12_LOAD="no"
27
Instrumentalb8a81292018-08-23 16:32:45 -050028for PROP in AAF_INITIAL_X509_P12 AAF_INITIAL_X509_PASSWORD AAF_SIGNER_P12 AAF_SIGNER_PASSWORD CADI_X509_ISSUERS; do
Instrumentalab502672018-08-20 14:31:35 -050029 if [ "${!PROP}" != "" ]; then
30 P12_LOAD='yes'
31 break;
32 fi
33done
34
35# First Time Run does a bit more setup
36if [ "$(docker volume ls | grep aaf_config)" = "" ] && [ ${P12_LOAD} = "yes" ]; then
37 echo "Initializing first aaf_config"
38 if [ "$(docker container ls | grep aaf_config_$USER)" = "" ]; then
39 PARAMS="bash"
40 run_it -t -d
41 else
42 echo "aaf_config_$USER is already running"
43 fi
44 docker container cp ${AAF_INITIAL_X509_P12} aaf_config_$USER:/opt/app/osaaf/local/org.osaaf.aaf.p12
45 docker container cp ${AAF_SIGNER_P12} aaf_config_$USER:/opt/app/osaaf/local/org.osaaf.aaf.signer.p12
46
47 encrypt_it cadi_keystore_password "${AAF_INITIAL_X509_PASSWORD}"
48 encrypt_it cm_ca.local "${AAF_SIGNER_PASSWORD}"
49
Instrumentalb8a81292018-08-23 16:32:45 -050050 set_it cadi_x509_issuers "${CADI_X509_ISSUERS}"
51
52
Instrumentalab502672018-08-20 14:31:35 -050053 echo -n "Stopping "
54 docker container stop aaf_config_$USER
55 echo -n "Removing "
56 docker container rm aaf_config_$USER
57fi
58
59PARAMS="$@"
60if [ "$PARAMS" != "" ]; then
61 run_it -it --rm
62fi
63