Skip to content

Commit

Permalink
Merge pull request #602 from nsacyber/v3_issue_599
Browse files Browse the repository at this point in the history
Added check for existing aca.properties in the ACA setup files
  • Loading branch information
iadgovuser29 authored Oct 4, 2023
2 parents 11b7ffd + 825d5de commit 0438198
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 12 additions & 1 deletion package/scripts/db/db_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions package/scripts/pki/pki_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0438198

Please sign in to comment.