Skip to content

Commit

Permalink
CSP-812: Accept yaml config file as script argument in bootstrap scri…
Browse files Browse the repository at this point in the history
…pts (#643)
  • Loading branch information
akatona84 authored Jan 22, 2020
1 parent 7e524f6 commit e64e11d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 7 additions & 2 deletions bootstrap/bootstrap-storage-initenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ done

printUsage() {
cat <<-EOF
USAGE: $0 admin-jdbc-url admin-username admin-password target-username target-password target-database
USAGE: $0 admin-jdbc-url admin-username admin-password target-username target-password target-database [config file path]
config file path : optional, "${CONFIG_FILE_PATH}" used if omitted
EOF
}

Expand All @@ -58,5 +60,8 @@ then
exit 1
fi

[[ $# -gt 6 ]] && CONFIG_FILE_PATH="${7}"

echo "Using Configuration file: ${CONFIG_FILE_PATH}"
${JAVA} -Dbootstrap.dir=$BOOTSTRAP_DIR -cp ${CLASSPATH} ${INITIALIZER_MAIN_CLASS} -m ${MYSQL_JAR_URL_PATH} -c ${CONFIG_FILE_PATH} --admin-jdbc-url ${1} --admin-username ${2} --admin-password ${3} --target-username ${4} --target-password ${5} --target-database ${6}
${JAVA} -Dbootstrap.dir=$BOOTSTRAP_DIR -cp ${CLASSPATH} ${INITIALIZER_MAIN_CLASS} -m ${MYSQL_JAR_URL_PATH} -c ${CONFIG_FILE_PATH} \
--admin-jdbc-url ${1} --admin-username ${2} --admin-password ${3} --target-username ${4} --target-password ${5} --target-database ${6}
13 changes: 8 additions & 5 deletions bootstrap/bootstrap-storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ execute() {

printUsage() {
cat <<-EOF
USAGE: $0 [create|migrate|info|validate|drop|drop-create|repair|check-connection]
USAGE: $0 [create|migrate|info|validate|drop|drop-create|repair|check-connection] [config file path]
create : Creates the tables. The target database should be empty
migrate : Migrates the database to the latest version or creates the tables if the database is empty. Use "info" to see the current version and the pending migrations
info : Shows the list of migrations applied and the pending migration waiting to be applied on the target database
Expand All @@ -68,18 +68,21 @@ USAGE: $0 [create|migrate|info|validate|drop|drop-create|repair|check-connection
drop-create : Drops and recreates all the tables in the target database.
repair : Repairs the DATABASE_CHANGE_LOG table which is used to track all the migrations on the target database.
This involves removing entries for the failed migrations and update the checksum of migrations already applied on the target databsase.
check-connection : Checks if a connection can be sucessfully obtained for the target database
check-connection : Checks if a connection can be successfully obtained for the target database
config file path : optional, "${CONFIG_FILE_PATH}" used if omitted
EOF
}

if [ $# -gt 1 ]
if [[ $# -gt 2 ]]
then
echo "More than one argument specified, please use only one of the below options"
echo "More than two argument specified, please use only one of the below options"
printUsage
exit 1
fi

opt="$1"
[[ $# -eq 2 ]] && CONFIG_FILE_PATH="${2}"

case "${opt}" in
create | drop | migrate | info | validate | repair | check-connection )
Expand All @@ -92,4 +95,4 @@ drop-create )
printUsage
exit 1
;;
esac
esac

0 comments on commit e64e11d

Please sign in to comment.