Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 1 | # This script is run when starting aaf_config Container. |
| 2 | # It needs to cover the cases where the initial data doesn't exist, and when it has already been configured (don't overwrite) |
| 3 | # |
| 4 | JAVA=/usr/bin/java |
| 5 | |
| 6 | # Only load Identities once |
| 7 | if [ ! -e /opt/app/osaaf/data/identities.dat ]; then |
| 8 | mkdir -p /opt/app/osaaf/data |
| 9 | cp /opt/app/aaf_config/data/sample.identities.dat /opt/app/osaaf/data/identities.dat |
| 10 | fi |
| 11 | |
| 12 | # Only initialize once, automatically... |
| 13 | if [ ! -e /opt/app/osaaf/local/org.osaaf.aaf.props ]; then |
| 14 | for D in local; do |
| 15 | rsync -avzh /opt/app/aaf_config/$D/org.osaaf.aaf* /opt/app/osaaf/$D |
| 16 | done |
| 17 | for D in public etc logs; do |
| 18 | rsync -avzh --exclude=.gitignore /opt/app/aaf_config/$D/* /opt/app/osaaf/$D |
| 19 | done |
| 20 | $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar config osaaf@aaf.osaaf.org \ |
| 21 | cadi_etc_dir=/opt/app/osaaf/local \ |
| 22 | cadi_prop_files=/opt/app/aaf_config/local/initialConfig.props:/opt/app/aaf_config/local/aaf.props \ |
| 23 | cadi_latitude=38.4329 \ |
| 24 | cadi_longitude=-90.43248 |
| 25 | #cp /opt/app/aaf_config/ |
| 26 | else |
| 27 | CMD=$2 |
| 28 | shift |
| 29 | if [ "$CMD" = "" ]; then |
| 30 | echo "AAF already configured for this Volume" |
| 31 | else |
| 32 | case "$CMD" in |
| 33 | ls) |
| 34 | echo ls requested |
| 35 | find /opt/app/osaaf -depth |
| 36 | ;; |
| 37 | cat) |
| 38 | if [ "$1" = "" ]; then |
| 39 | echo "usage: cat <file... ONLY files ending in .props>" |
| 40 | else |
| 41 | if [[ $1 == *.props ]]; then |
| 42 | echo |
| 43 | echo "## CONTENTS OF $3" |
| 44 | echo |
| 45 | cat $1 |
| 46 | else |
| 47 | echo "### ERROR ####" |
| 48 | echo " \"cat\" may only be used with files ending with \".props\"" |
| 49 | fi |
| 50 | fi |
| 51 | ;; |
| 52 | update) |
| 53 | for D in public data etc local logs; do |
| 54 | rsync -uh --exclude=.gitignore /opt/app/aaf_config/$D /opt/app/osaaf |
| 55 | done |
| 56 | ;; |
| 57 | validate) |
| 58 | echo "## validate requested" |
| 59 | $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar validate cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props |
| 60 | ;; |
| 61 | bash) |
| 62 | if [ ! "grep aaf_config ~/.bashrc" == "" ]; then |
| 63 | echo "alias cadi='/bin/bash /opt/app/aaf_config/bin/agent.sh $*'" >> ~/.bashrc |
| 64 | . ~/.bashrc |
| 65 | fi |
| 66 | shift |
| 67 | /bin/bash $* |
| 68 | ;; |
| 69 | encrypt) |
| 70 | echo $1 $2 $3 |
| 71 | cd /opt/app/osaaf/local |
| 72 | |
| 73 | for F in `grep -l $2 *.props`; do |
| 74 | echo "Changing $F" |
| 75 | PWD=`$JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar cadi digest $3 /opt/app/osaaf/local/org.osaaf.aaf.keyfile` |
| 76 | sed -i.old -e "s/\($2=\).*/\1enc=$PWD/" /opt/app/osaaf/local/org.osaaf.aaf.cred.props |
| 77 | cat $F |
| 78 | done |
| 79 | ;; |
| 80 | *) |
| 81 | $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar $* |
| 82 | esac |
| 83 | fi |
| 84 | fi |
| 85 | |