Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 2 | ######### |
| 3 | # ============LICENSE_START==================================================== |
| 4 | # org.onap.aaf |
| 5 | # =========================================================================== |
| 6 | # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. |
| 7 | # =========================================================================== |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # ============LICENSE_END==================================================== |
| 20 | # |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 21 | # This script is run when starting aaf_config Container. |
| 22 | # It needs to cover the cases where the initial data doesn't exist, and when it has already been configured (don't overwrite) |
| 23 | # |
Instrumental | fea400a | 2019-04-17 14:30:28 -0500 | [diff] [blame] | 24 | |
| 25 | echo "# Properties passed in" |
| 26 | for P in `env`; do |
| 27 | if [[ "$P" == cadi* ]] || [[ "$P" == aaf* ]] || [[ "$P" == HOSTNAME* ]]; then |
| 28 | S="${P/_helm/.helm}" |
| 29 | S="${S/_oom/.oom}" |
| 30 | echo "$S" |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | # Set from CAP Based PROPS, if necessary |
| 35 | aaf_env=${aaf_env:-"${AAF_ENV}"} |
Instrumental | 355b886 | 2019-06-06 19:33:19 -0500 | [diff] [blame] | 36 | aaf_deployed_version=${aaf_deployed_version:-"${VERSION}"} |
Instrumental | fea400a | 2019-04-17 14:30:28 -0500 | [diff] [blame] | 37 | cadi_latitude=${cadi_latitude:-"${LATITUDE}"} |
| 38 | cadi_longitude=${cadi_longitude:-"${LONGITUDE}"} |
| 39 | cadi_x509_issuers=${cadi_x509_issuers:-"${CADI_X509_ISSUERS}"} |
| 40 | aaf_locate_url=${aaf_locate_url:-"https://${HOSTNAME}:8095"} |
| 41 | |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 42 | JAVA=/usr/bin/java |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 43 | |
| 44 | OSAAF=/opt/app/osaaf |
| 45 | LOCAL=$OSAAF/local |
| 46 | DATA=$OSAAF/data |
| 47 | PUBLIC=$OSAAF/public |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 48 | CONFIG=/opt/app/aaf_config |
Instrumental | 5451a50 | 2018-10-10 18:51:33 -0500 | [diff] [blame] | 49 | |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 50 | JAVA_CADI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar org.onap.aaf.cadi.CmdLine" |
| 51 | JAVA_AGENT="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.props org.onap.aaf.cadi.configure.Agent" |
| 52 | JAVA_AAFCLI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.props org.onap.aaf.auth.cmd.AAFcli" |
Instrumental | e2fa0e6 | 2019-02-07 11:09:32 -0600 | [diff] [blame] | 53 | JAVA_AAFBATCH="$JAVA -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.batch.props -jar $CONFIG/bin/aaf-auth-batch-*-full.jar" |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 54 | |
Instrumental | 5451a50 | 2018-10-10 18:51:33 -0500 | [diff] [blame] | 55 | # If doesn't exist... still create |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 56 | mkdir -p $OSAAF |
Instrumental | 5451a50 | 2018-10-10 18:51:33 -0500 | [diff] [blame] | 57 | |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 58 | # If not created by separate PV, create |
| 59 | mkdir -p /opt/app/aaf/status |
| 60 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 61 | # Temp use for clarity of code |
| 62 | FILE= |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 63 | |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 64 | # Setup Bash, first time only |
Instrumental | e2fa0e6 | 2019-02-07 11:09:32 -0600 | [diff] [blame] | 65 | if [ ! -e "$HOME/.bashrc" ] || [ -z "$(grep cadi $HOME/.bashrc)" ]; then |
| 66 | echo "alias cadi='$JAVA_CADI \$*'" >>$HOME/.bashrc |
| 67 | echo "alias agent='$CONFIG/bin/agent.sh \$*'" >>$HOME/.bashrc |
| 68 | echo "alias aafcli='$JAVA_AAFCLI \$*'" >>$HOME/.bashrc |
| 69 | echo "alias batch='$JAVA_AAFBATCH \$*'" >>$HOME/.bashrc |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 70 | chmod a+x $CONFIG/bin/agent.sh |
Instrumental | e2fa0e6 | 2019-02-07 11:09:32 -0600 | [diff] [blame] | 71 | . $HOME/.bashrc |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 72 | fi |
| 73 | |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 74 | # Only load Identities once |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 75 | # echo "Check Identities" |
| 76 | FILE="$DATA/identities.dat" |
| 77 | if [ ! -e $FILE ]; then |
| 78 | mkdir -p $DATA |
| 79 | cp $CONFIG/data/sample.identities.dat $FILE |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 80 | echo "Set Identities" |
| 81 | INITIALIZED="true" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 82 | fi |
| 83 | |
Instrumental | 513471c | 2019-05-01 13:35:47 -0500 | [diff] [blame] | 84 | # Should we clean up? |
| 85 | if [ ! -e "${LOCAL}/VERSION" ] || [ "${VERSION}" != "$(cat ${LOCAL}/VERSION)" ]; then |
| 86 | echo "Clean up directory ${LOCAL}" |
| 87 | rm -Rf ${LOCAL}/org.osaaf.aaf.*props ${LOCAL}/org.osaaf.aaf.p12 |
| 88 | ls ${LOCAL} |
| 89 | fi |
| 90 | echo "${VERSION}" > $LOCAL/VERSION |
| 91 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 92 | # Load up Cert/X509 Artifacts |
| 93 | # echo "Check Signer Keyfile" |
| 94 | FILE="$LOCAL/org.osaaf.aaf.signer.p12" |
| 95 | if [ ! -e $FILE ]; then |
| 96 | mkdir -p $LOCAL |
| 97 | mkdir -p $PUBLIC |
| 98 | if [ -e $CONFIG/cert/org.osaaf.aaf.signer.p12 ]; then |
| 99 | cp $CONFIG/cert/org.osaaf.aaf.signer.p12 $FILE |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 100 | echo "Installed Signer P12" |
| 101 | INITIALIZED="true" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 102 | else |
| 103 | echo "Decode" |
| 104 | base64 -d $CONFIG/cert/demoONAPsigner.p12.b64 > $FILE |
| 105 | base64 -d $CONFIG/cert/truststoreONAP.p12.b64 > $PUBLIC/truststoreONAP.p12 |
| 106 | base64 -d $CONFIG/cert/truststoreONAPall.jks.b64 > $PUBLIC/truststoreONAPall.jks |
| 107 | ln -s $PUBLIC/truststoreONAPall.jks $LOCAL |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 108 | cp $CONFIG/cert/AAF_RootCA.cer $PUBLIC |
| 109 | CM_TRUST_CAS="$PUBLIC/AAF_RootCA.cer" |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 110 | echo "Setup ONAP Test CAs and Signers" |
| 111 | INITIALIZED="true" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 112 | fi |
| 113 | fi |
| 114 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 115 | FILE="$LOCAL/org.osaaf.aaf.p12" |
| 116 | if [ ! -e $FILE ]; then |
| 117 | if [ -e $CONFIG/cert/org.osaaf.aaf.p12 ]; then |
| 118 | cp $CONFIG/cert/org.osaaf.aaf.p12 $FILE |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 119 | echo "Installed AAF P12" |
| 120 | INITIALIZED="true" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 121 | else |
| 122 | echo "Bootstrap Creation of Keystore from Signer" |
| 123 | cd $CONFIG/CA |
| 124 | |
Instrumental | 513471c | 2019-05-01 13:35:47 -0500 | [diff] [blame] | 125 | # Redo all of this after Dublin |
| 126 | export cadi_x509_issuers="CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US" |
| 127 | export signer_subj="/CN=intermediateCA_9/OU=OSAAF/O=ONAP/C=US" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 128 | bash bootstrap.sh $LOCAL/org.osaaf.aaf.signer.p12 'something easy' |
| 129 | cp aaf.bootstrap.p12 $FILE |
| 130 | if [ -n "$CADI_X509_ISSUERS" ]; then |
| 131 | CADI_X509_ISSUERS="$CADI_X509_ISSUERS:" |
| 132 | fi |
| 133 | BOOT_ISSUER="$(cat aaf.bootstrap.issuer)" |
| 134 | CADI_X509_ISSUERS="$CADI_X509_ISSUERS$BOOT_ISSUER" |
| 135 | |
| 136 | I=${BOOT_ISSUER##CN=};I=${I%%,*} |
| 137 | CM_CA_PASS="something easy" |
| 138 | CM_CA_LOCAL="org.onap.aaf.auth.cm.ca.LocalCA,$LOCAL/org.osaaf.aaf.signer.p12;aaf_intermediate_9;enc:" |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 139 | CM_TRUST_CAS="$PUBLIC/AAF_RootCA.cer" |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 140 | echo "Generated ONAP Test AAF certs" |
| 141 | INITIALIZED="true" |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 142 | fi |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 143 | fi |
| 144 | |
| 145 | # Only initialize once, automatically... |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 146 | if [ ! -e $LOCAL/org.osaaf.aaf.props ]; then |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 147 | cp $CONFIG/local/org.osaaf.aaf* $LOCAL |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 148 | for D in public etc logs; do |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 149 | mkdir -p $OSAAF/$D |
| 150 | cp $CONFIG/$D/* $OSAAF/$D |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 151 | done |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 152 | |
| 153 | TMP=$(mktemp) |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 154 | for P in `env`; do |
Instrumental | fea400a | 2019-04-17 14:30:28 -0500 | [diff] [blame] | 155 | if [[ "$P" == aaf_* ]] || [[ "$P" == cadi_* ]]; then |
Instrumental | 4ac37bf | 2019-04-10 13:01:30 -0500 | [diff] [blame] | 156 | S="${P/_helm/.helm}" |
| 157 | S="${S/_oom/.oom}" |
| 158 | echo "$S" >> ${TMP} |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 159 | fi |
| 160 | done |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 161 | cat $TMP |
| 162 | |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 163 | $JAVA_AGENT config \ |
| 164 | aaf@aaf.osaaf.org \ |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 165 | cadi_etc_dir=$LOCAL \ |
Instrumental | f64f482 | 2019-04-30 10:19:21 -0500 | [diff] [blame] | 166 | cadi_latitude=${cadi_latitude} \ |
| 167 | cadi_longitude=${cadi_longitude} \ |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 168 | cadi_prop_files=$CONFIG/local/initialConfig.props:$CONFIG/local/aaf.props:${TMP} |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 169 | rm ${TMP} |
Instrumental | b3a6814 | 2019-07-24 14:42:22 -0500 | [diff] [blame] | 170 | echo "cm_always_ignore_ips=${cm_always_ignore_ips:=false}" >> $LOCAL/org.osaaf.aaf.props; |
Instrumental | 196000b | 2018-10-05 19:30:59 -0500 | [diff] [blame] | 171 | |
| 172 | # Cassandra Config stuff |
| 173 | # Default is expect a Cassandra on same Node |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 174 | CASS_HOST=${CASS_HOST:="aaf-cass"} |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 175 | CASS_PASS=$($JAVA_CADI digest "${CASSANDRA_PASSWORD:-cassandra}" $LOCAL/org.osaaf.aaf.keyfile) |
Instrumental | 196000b | 2018-10-05 19:30:59 -0500 | [diff] [blame] | 176 | CASS_NAME=${CASS_HOST/:*/} |
Instrumental | fea400a | 2019-04-17 14:30:28 -0500 | [diff] [blame] | 177 | sed -i.backup -e "s/\\(cassandra.clusters=\\).*/\\1${CASSANDRA_CLUSTER:=$CASS_HOST}/" \ |
Instrumental | 196000b | 2018-10-05 19:30:59 -0500 | [diff] [blame] | 178 | -e "s/\\(cassandra.clusters.user=\\).*/\\1${CASSANDRA_USER:=cassandra}/" \ |
| 179 | -e "s/\\(cassandra.clusters.password=enc:\\).*/\\1$CASS_PASS/" \ |
| 180 | -e "s/\\(cassandra.clusters.port=\\).*/\\1${CASSANDRA_PORT:=9042}/" \ |
| 181 | $LOCAL/org.osaaf.aaf.cassandra.props |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 182 | |
| 183 | if [ -n "$CM_CA_LOCAL" ]; then |
| 184 | if [ -n "$CM_CA_PASS" ]; then |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 185 | CM_CA_LOCAL=$CM_CA_LOCAL$($JAVA_CADI digest "$CM_CA_PASS" $LOCAL/org.osaaf.aaf.keyfile) |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 186 | fi |
| 187 | # Move and copy method, rather than sed, because of slashes in CM_CA_LOCAL makes too complex |
| 188 | FILE=$LOCAL/org.osaaf.aaf.cm.ca.props |
| 189 | mv $FILE $FILE.backup |
| 190 | grep -v "cm_ca.local=" $FILE.backup > $FILE |
| 191 | echo "cm_ca.local=$CM_CA_LOCAL" >> $FILE |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 192 | echo "cm_trust_cas=$CM_TRUST_CAS" >> $FILE |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 193 | fi |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 194 | echo "Created AAF Initial Configurations" |
| 195 | INITIALIZED="true" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 196 | fi |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 197 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 198 | |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 199 | # Now run a command |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 200 | CMD=$1 |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 201 | if [ -z "$CMD" ]; then |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 202 | if [ -n "$INITIALIZED" ]; then |
| 203 | echo "Initialization Complete" |
| 204 | else |
| 205 | echo "No Additional Initialization required" |
| 206 | fi |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 207 | else |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 208 | shift |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 209 | case "$CMD" in |
| 210 | ls) |
| 211 | echo ls requested |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 212 | find $OSAAF -depth |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 213 | ;; |
| 214 | cat) |
| 215 | if [ "$1" = "" ]; then |
| 216 | echo "usage: cat <file... ONLY files ending in .props>" |
| 217 | else |
| 218 | if [[ $1 == *.props ]]; then |
| 219 | echo |
| 220 | echo "## CONTENTS OF $3" |
| 221 | echo |
| 222 | cat "$1" |
| 223 | else |
| 224 | echo "### ERROR ####" |
| 225 | echo " \"cat\" may only be used with files ending with \".props\"" |
| 226 | fi |
| 227 | fi |
| 228 | ;; |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 229 | validate) |
| 230 | echo "## validate requested" |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 231 | $JAVA_AAFCLI perm list user aaf@aaf.osaaf.org |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 232 | ;; |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 233 | onap) |
Instrumental | 284ad0a | 2018-10-24 07:01:09 -0500 | [diff] [blame] | 234 | #echo Initializing ONAP configurations. |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 235 | ;; |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 236 | bash) |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 237 | shift |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 238 | cd $LOCAL || exit |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 239 | exec /bin/bash -c "$@" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 240 | ;; |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 241 | setProp) |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 242 | cd $LOCAL || exit |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 243 | FILES=$(grep -l "$1" ./*.props) |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 244 | if [ -z "$FILES" ]; then |
| 245 | if [ -z "$3" ]; then |
| 246 | FILES=org.osaaf.aaf.props |
| 247 | else |
| 248 | FILES="$3" |
| 249 | fi |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 250 | ADD=Y |
| 251 | fi |
| 252 | for F in $FILES; do |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 253 | if [ "$ADD" = "Y" ]; then |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 254 | echo "Changing $1 for $F" |
Instrumental | aeb80c8 | 2018-08-21 10:24:08 -0500 | [diff] [blame] | 255 | echo "$1=$2" >> $F |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 256 | else |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 257 | echo "Changing $1 in $F" |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 258 | sed -i.backup -e "s/\\(${1}=\\).*/\\1${2}/" $F |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 259 | fi |
| 260 | cat $F |
| 261 | done |
| 262 | ;; |
| 263 | encrypt) |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 264 | cd $LOCAL || exit |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 265 | echo $1 |
| 266 | FILES=$(grep -l "$1" ./*.props) |
| 267 | if [ "$FILES" = "" ]; then |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 268 | FILES=$LOCAL/org.osaaf.aaf.cred.props |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 269 | ADD=Y |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 270 | fi |
| 271 | for F in $FILES; do |
| 272 | echo "Changing $1 in $F" |
| 273 | if [ "$2" = "" ]; then |
| 274 | read -r -p "Password (leave blank to cancel): " -s ORIG_PW |
| 275 | echo " " |
| 276 | if [ "$ORIG_PW" = "" ]; then |
| 277 | echo canceling... |
| 278 | break |
| 279 | fi |
| 280 | else |
| 281 | ORIG_PW="$2" |
| 282 | fi |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 283 | PWD=$($JAVA_CADI digest "$ORIG_PW" $LOCAL/org.osaaf.aaf.keyfile) |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 284 | if [ "$ADD" = "Y" ]; then |
| 285 | echo "$1=enc:$PWD" >> $F |
| 286 | else |
| 287 | sed -i.backup -e "s/\\($1.*enc:\\).*/\\1$PWD/" $F |
| 288 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 289 | cat $F |
| 290 | done |
| 291 | ;; |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 292 | taillog) |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 293 | sh $OSAAF/logs/taillog |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 294 | ;; |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 295 | wait) |
| 296 | bash $CONFIG/bin/pod_wait.sh wait $1 |
| 297 | ;; |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 298 | --help | -?) |
| 299 | case "$1" in |
| 300 | "") |
| 301 | echo "--- Agent Container Comands ---" |
| 302 | echo " ls - Lists all files in Configuration" |
| 303 | echo " cat <file.props>> - Shows the contents (Prop files only)" |
| 304 | echo " validate - Runs a test using Configuration" |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 305 | echo " setProp <tag> [<value>] - set value on 'tag' (if no value, it will be queried from config)" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 306 | echo " encrypt <tag> [<pass>] - set passwords on Configuration (if no pass, it will be queried)" |
| 307 | echo " bash - run bash in Container" |
| 308 | echo " Note: the following aliases are preset" |
| 309 | echo " cadi - CADI CmdLine tool" |
| 310 | echo " agent - Agent Java tool (see above help)" |
| 311 | echo "" |
| 312 | echo " --help|-? [cadi|agent] - This help, cadi help or agent help" |
| 313 | ;; |
| 314 | cadi) |
| 315 | echo "--- cadi Tool Comands ---" |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 316 | $JAVA_CADI |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 317 | ;; |
| 318 | agent) |
| 319 | echo "--- agent Tool Comands ---" |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 320 | $JAVA_AGENT |
| 321 | ;; |
| 322 | aafcli) |
| 323 | echo "--- aafcli Tool Comands ---" |
| 324 | $JAVA_AAFCLI |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 325 | ;; |
| 326 | esac |
| 327 | echo "" |
| 328 | ;; |
| 329 | *) |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 330 | $JAVA_AGENT "$CMD" "$@" cadi_prop_files=$LOCAL/org.osaaf.aaf.props |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 331 | ;; |
| 332 | esac |
| 333 | fi |