diff --git a/package/scripts/db/db_create.sh b/package/scripts/db/db_create.sh index e723ec9f2..3c67601d0 100755 --- a/package/scripts/db/db_create.sh +++ b/package/scripts/db/db_create.sh @@ -41,8 +41,19 @@ source $SCRIPT_DIR/mysql_util.sh source $ACA_PROP_FILE check_mysql_root_pwd () { - # Check if DB root password needs to be obtained + # Check if DB root password needs to be obtained via env variable or existing property file + if [ -z "$HIRS_MYSQL_ROOT_PWD" ]; then + # Check if property file exists and look for properties + if [ -f $ACA_PROP_FILE ]; then + echo "Found existing aca.properties, using existing variables..." + source $ACA_PROP_FILE + if [ ! -z $hirs_pki_password ]; then PKI_PASS=$hirs_pki_password; fi + if [ ! -z $mysql_admin_password ]; then HIRS_MYSQL_ROOT_PWD=$mysql_admin_password; fi + if [ ! -z $hirs_db_password ]; then HIRS_DB_PWD=$hirs_db_password; fi + fi + fi + if [ -z $HIRS_MYSQL_ROOT_PWD ]; then # Create a 32 character random password echo "Using randomly generated password for the DB admin" | tee -a "$LOG_FILE" diff --git a/package/scripts/pki/pki_setup.sh b/package/scripts/pki/pki_setup.sh index 5a28142b3..5ad18e68f 100755 --- a/package/scripts/pki/pki_setup.sh +++ b/package/scripts/pki/pki_setup.sh @@ -21,15 +21,24 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; ) mkdir -p $HIRS_CONF_DIR $LOG_DIR echo "SCRIPT_DIR is $SCRIPT_DIR" | tee -a "$LOG_FILE" -if [ -z "$1" ]; then +if [ -z "$LOG_FILE" ]; then LOG_FILE="$LOG_DIR$LOG_FILE_NAME" echo "using log file $LOG_FILE" | tee -a "$LOG_FILE" fi -if [ -z "$2" ]; then - PKI_PASS=$(head -c 64 /dev/urandom | md5sum | tr -dc 'a-zA-Z0-9') - echo "Using randomly generated password for the PKI key password" | tee -a "$LOG_FILE" - echo "Using pki password=$PKI_PASS" +if [ -z "$PKI_PASS" ]; then + if [ -f $ACA_PROP ]; then + source $ACA_PROP + if [ ! -z $hirs_pki_password ]; then + PKI_PASS=$hirs_pki_password + fi + fi +fi + +if [ -z "$PKI_PASS" ]; then + PKI_PASS=$(head -c 64 /dev/urandom | md5sum | tr -dc 'a-zA-Z0-9') + echo "Using randomly generated password for the PKI key password" | tee -a "$LOG_FILE" + echo "Using pki password=$PKI_PASS" fi # Check for sudo or root user