Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | . ./d.props |
| 3 | |
Instrumental | ab50267 | 2018-08-20 14:31:35 -0500 | [diff] [blame] | 4 | function run_it() { |
| 5 | docker run $@ \ |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 6 | --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 \ |
Instrumental | e44d2f7 | 2018-08-16 17:22:45 -0500 | [diff] [blame] | 14 | $PREFIX${ORG}/${PROJECT}/aaf_config:${VERSION} \ |
Instrumental | ab50267 | 2018-08-20 14:31:35 -0500 | [diff] [blame] | 15 | /bin/bash $PARAMS |
| 16 | } |
| 17 | |
| 18 | function encrypt_it() { |
| 19 | docker exec -t aaf_config_$USER /bin/bash /opt/app/aaf_config/bin/agent.sh NOOP encrypt "$1" "$2" |
| 20 | } |
| 21 | |
Instrumental | b8a8129 | 2018-08-23 16:32:45 -0500 | [diff] [blame^] | 22 | function set_it() { |
| 23 | docker exec -t aaf_config_$USER /bin/bash /opt/app/aaf_config/bin/agent.sh NOOP setProp "$1" "$2" |
| 24 | } |
| 25 | |
Instrumental | ab50267 | 2018-08-20 14:31:35 -0500 | [diff] [blame] | 26 | P12_LOAD="no" |
| 27 | |
Instrumental | b8a8129 | 2018-08-23 16:32:45 -0500 | [diff] [blame^] | 28 | for PROP in AAF_INITIAL_X509_P12 AAF_INITIAL_X509_PASSWORD AAF_SIGNER_P12 AAF_SIGNER_PASSWORD CADI_X509_ISSUERS; do |
Instrumental | ab50267 | 2018-08-20 14:31:35 -0500 | [diff] [blame] | 29 | if [ "${!PROP}" != "" ]; then |
| 30 | P12_LOAD='yes' |
| 31 | break; |
| 32 | fi |
| 33 | done |
| 34 | |
| 35 | # First Time Run does a bit more setup |
| 36 | if [ "$(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 | |
Instrumental | b8a8129 | 2018-08-23 16:32:45 -0500 | [diff] [blame^] | 50 | set_it cadi_x509_issuers "${CADI_X509_ISSUERS}" |
| 51 | |
| 52 | |
Instrumental | ab50267 | 2018-08-20 14:31:35 -0500 | [diff] [blame] | 53 | echo -n "Stopping " |
| 54 | docker container stop aaf_config_$USER |
| 55 | echo -n "Removing " |
| 56 | docker container rm aaf_config_$USER |
| 57 | fi |
| 58 | |
| 59 | PARAMS="$@" |
| 60 | if [ "$PARAMS" != "" ]; then |
| 61 | run_it -it --rm |
| 62 | fi |
| 63 | |