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)
6 AAF_INTERFACE_VERSION=2.1
8 # Extract Name, Domain and NS from FQI
9 FQIA=($(echo ${APP_FQI} | tr '@' '\n'))
12 # Reverse DOMAIN for NS
13 FQIA_E=($(echo ${FQI_DOMAIN} | tr '.' '\n'))
14 for (( i=( ${#FQIA_E[@]} -1 ); i>0; i-- )); do
15 NS=${NS}${FQIA_E[i]}'.'
20 # Setup SSO info for Deploy ID
21 function sso_encrypt() {
22 $JAVA -cp /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar org.onap.aaf.cadi.CmdLine digest ${1} ~/.aaf/keyfile
25 if [ ! -e " ~/.aaf/keyfile" ]; then
28 $JAVA -cp /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar org.onap.aaf.cadi.CmdLine keygen ~/.aaf/keyfile
29 chmod 400 ~/.aaf/keyfile
30 echo cadi_latitude=${LATITUDE} > ${SSO}
31 echo cadi_longitude=${LONGITUDE} >> ${SSO}
32 echo aaf_id=${DEPLOY_FQI} >> ${SSO}
33 if [ ! "${DEPLOY_PASSWORD}" = "" ]; then
34 echo aaf_password=enc:$(sso_encrypt ${DEPLOY_PASSWORD}) >> ${SSO}
36 echo aaf_locate_url=https://${AAF_FQDN}:8095 >> ${SSO}
37 echo aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:${AAF_INTERFACE_VERSION} >> ${SSO}
38 echo cadi_truststore=$(ls /opt/app/aaf_config/public/*trust*) >> ${SSO}
39 echo cadi_truststore_password=enc:$(sso_encrypt changeit) >> ${SSO}
42 # Only initialize once, automatically...
43 if [ ! -e /opt/app/osaaf/local/${NS}.props ]; then
45 rsync -avzh --exclude=.gitignore /opt/app/aaf_config/$D/* /opt/app/osaaf/$D
49 $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar config $APP_FQI \
50 cadi_etc_dir=/opt/app/osaaf/local
53 $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar place ${APP_FQI} ${APP_FQDN}
56 $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar validate \
57 cadi_prop_files=/opt/app/osaaf/local/${NS}.props
62 if [ ! "$CMD" = "" ]; then
68 find /opt/app/osaaf -depth
71 if [ "$1" = "" ]; then
72 echo "usage: cat <file... ONLY files ending in .props>"
74 if [[ $1 == *.props ]]; then
76 echo "## CONTENTS OF $3"
81 echo " \"cat\" may only be used with files ending with \".props\""
87 rsync -uh --exclude=.gitignore /opt/app/aaf_config/$D/* /opt/app/osaaf/$D
91 echo "## validate requested"
92 $JAVA -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar validate cadi_prop_files=/opt/app/osaaf/local/${NS}.props
95 if [ ! -e ~/.bash_aliases ]; then
96 echo "alias cadi='$JAVA -cp /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar org.onap.aaf.cadi.CmdLine \$*'" >~/.bash_aliases
97 echo "alias agent='$JAVA -cp /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar org.onap.aaf.cadi.configure.Agent \$*'" >>~/.bash_aliases
100 cd /opt/app/osaaf/local || exit
104 cd /opt/app/osaaf/local || exit
105 FILES=$(grep -l "$1" ./*.props)
106 if [ "$FILES" = "" ]; then
111 echo "Changing $1 in $F"
112 if [ "$ADD" = "Y" ]; then
115 sed -i.backup -e "s/\\(${1}.*=\\).*/\\1${2}/" $F
121 cd /opt/app/osaaf/local || exit
123 FILES=$(grep -l "$1" ./*.props)
124 if [ "$FILES" = "" ]; then
125 FILES=/opt/app/osaaf/local/${NS}.cred.props
129 echo "Changing $1 in $F"
130 if [ "$2" = "" ]; then
131 read -r -p "Password (leave blank to cancel): " -s ORIG_PW
133 if [ "$ORIG_PW" = "" ]; then
140 PWD=$("$JAVA" -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar cadi digest "$ORIG_PW" /opt/app/osaaf/local/${NS}.keyfile)
141 if [ "$ADD" = "Y" ]; then
142 echo "$1=enc:$PWD" >> $F
144 sed -i.backup -e "s/\\($1.*enc:\\).*/\\1$PWD/" $F
150 sh /opt/app/osaaf/logs/taillog
155 echo "--- Agent Container Comands ---"
156 echo " ls - Lists all files in Configuration"
157 echo " cat <file.props>> - Shows the contents (Prop files only)"
158 echo " validate - Runs a test using Configuration"
159 echo " setProp <tag> [<value>] - set value on 'tag' (if no value, it will be queried from config)"
160 echo " encrypt <tag> [<pass>] - set passwords on Configuration (if no pass, it will be queried)"
161 echo " bash - run bash in Container"
162 echo " Note: the following aliases are preset"
163 echo " cadi - CADI CmdLine tool"
164 echo " agent - Agent Java tool (see above help)"
166 echo " --help|-? [cadi|agent] - This help, cadi help or agent help"
169 echo "--- cadi Tool Comands ---"
170 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/${NS}.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar cadi | tail -n +6
173 echo "--- agent Tool Comands ---"
174 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/${NS}.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar
180 $JAVA -Dcadi_prop_files=/opt/app/osaaf/local/${NS}.props -jar /opt/app/aaf_config/bin/aaf-cadi-aaf-*-full.jar "$CMD" "$@"