blob: efd4fe3757e6af3b1c5c90f9163203ad593ef04b [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
22P12_LOAD="no"
23
24for PROP in AAF_INITIAL_X509_P12 AAF_INITIAL_X509_PASSWORD AAF_SIGNER_P12 AAF_SIGNER_PASSWORD; do
25 if [ "${!PROP}" != "" ]; then
26 P12_LOAD='yes'
27 break;
28 fi
29done
30
31# First Time Run does a bit more setup
32if [ "$(docker volume ls | grep aaf_config)" = "" ] && [ ${P12_LOAD} = "yes" ]; then
33 echo "Initializing first aaf_config"
34 if [ "$(docker container ls | grep aaf_config_$USER)" = "" ]; then
35 PARAMS="bash"
36 run_it -t -d
37 else
38 echo "aaf_config_$USER is already running"
39 fi
40 docker container cp ${AAF_INITIAL_X509_P12} aaf_config_$USER:/opt/app/osaaf/local/org.osaaf.aaf.p12
41 docker container cp ${AAF_SIGNER_P12} aaf_config_$USER:/opt/app/osaaf/local/org.osaaf.aaf.signer.p12
42
43 encrypt_it cadi_keystore_password "${AAF_INITIAL_X509_PASSWORD}"
44 encrypt_it cm_ca.local "${AAF_SIGNER_PASSWORD}"
45
46 echo -n "Stopping "
47 docker container stop aaf_config_$USER
48 echo -n "Removing "
49 docker container rm aaf_config_$USER
50fi
51
52PARAMS="$@"
53if [ "$PARAMS" != "" ]; then
54 run_it -it --rm
55fi
56