2 # This script is run when starting aaf_config Container.
3 # It needs to cover the cases where the initial data doesn't exist, and when it has already been configured (don't overwrite)
7 # Only load Identities once
8 if [ ! -e /opt/app/osaaf/data/identities.dat ]; then
9 mkdir -p /opt/app/osaaf/data
10 cp /opt/app/aaf_config/data/sample.identities.dat /opt/app/osaaf/data/identities.dat
13 # Only initialize once, automatically...
14 if [ ! -e /opt/app/osaaf/local/org.osaaf.aaf.props ]; then
15 rsync -avzh --exclude=.gitignore /opt/app/aaf_config/local/org.osaaf.aaf* /opt/app/osaaf/local
16 for D in public etc logs; do
17 rsync -avzh --exclude=.gitignore /opt/app/aaf_config/$D/* /opt/app/osaaf/$D
19 $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar config osaaf@aaf.osaaf.org \
20 cadi_etc_dir=/opt/app/osaaf/local \
21 cadi_prop_files=/opt/app/aaf_config/local/initialConfig.props:/opt/app/aaf_config/local/aaf.props \
22 cadi_latitude=38.4329 \
23 cadi_longitude=-90.43248
28 if [ ! "$CMD" = "" ]; then
34 find /opt/app/osaaf -depth
37 if [ "$1" = "" ]; then
38 echo "usage: cat <file... ONLY files ending in .props>"
40 if [[ $1 == *.props ]]; then
42 echo "## CONTENTS OF $3"
47 echo " \"cat\" may only be used with files ending with \".props\""
52 rsync -uh --exclude=.gitignore /opt/app/aaf_config/local/org.osaaf.aaf* /opt/app/osaaf/local
53 for D in public data etc logs; do
54 rsync -uh --exclude=.gitignore /opt/app/aaf_config/$D/* /opt/app/osaaf/$D
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
62 echo "alias agent='/bin/bash /opt/app/aaf_config/bin/agent.sh EMPTY \$*'" >>~/.bashrc
63 if [ ! "$(grep aaf_config ~/.bashrc)" = "" ]; then
64 echo "alias cadi='/bin/bash /opt/app/aaf_config/bin/agent.sh EMPTY cadi \$*'" >>~/.bashrc
65 echo "alias agent='/bin/bash /opt/app/aaf_config/bin/agent.sh EMPTY \$*'" >>~/.bashrc
69 cd /opt/app/osaaf/local || exit
73 cd /opt/app/osaaf/local || exit
74 FILES=$(grep -l "$1" ./*.props)
75 if [ "$FILES" = "" ]; then
76 FILES=/opt/app/osaaf/local/org.osaaf.aaf.cred.props
77 echo "$1=enc:" >>FILES
80 echo "Changing $1 in $F"
81 if [ "$2" = "" ]; then
82 read -r -p "Password (leave blank to cancel): " -s ORIG_PW
84 if [ "$ORIG_PW" = "" ]; then
91 PWD=$("$JAVA" -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar cadi digest "$ORIG_PW" /opt/app/osaaf/local/org.osaaf.aaf.keyfile)
92 sed -i.backup -e "s/\\($1.*enc:\\).*/\\1$PWD/" $F
99 echo "--- Agent Container Comands ---"
100 echo " ls - Lists all files in Configuration"
101 echo " cat <file.props>> - Shows the contents (Prop files only)"
102 echo " validate - Runs a test using Configuration"
103 echo " encrypt <tag> [<pass>] - set passwords on Configuration (if no pass, it will be queried)"
104 echo " bash - run bash in Container"
105 echo " Note: the following aliases are preset"
106 echo " cadi - CADI CmdLine tool"
107 echo " agent - Agent Java tool (see above help)"
109 echo " --help|-? [cadi|agent] - This help, cadi help or agent help"
112 echo "--- cadi Tool Comands ---"
113 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar cadi | tail -n +6
116 echo "--- agent Tool Comands ---"
117 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar
123 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar "$CMD" "$@"