mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-20 05:28:22 +00:00
cleaned up dnf install and dnf remove
This commit is contained in:
parent
5330318439
commit
b5c4d86430
@ -120,7 +120,22 @@ ospackage {
|
|||||||
from '../HIRS_AttestationCA/src/main/resources/component-class.json'
|
from '../HIRS_AttestationCA/src/main/resources/component-class.json'
|
||||||
}
|
}
|
||||||
// Post Install
|
// Post Install
|
||||||
|
// println "*** Checking MYSQL Configuration ...."
|
||||||
|
// println " Myql password is $System.env.HIRS_MYSQL_ROOT_PWD"
|
||||||
|
// println " Myql password is ${System.getenv('HIRS_MYSQL_ROOT_PWD')} "
|
||||||
|
|
||||||
|
// if ( "$System.env.HIRS_MYSQL_ROOT_PWD".compareTo("null") == 0 ) {
|
||||||
|
// println "Gradle: Mysql Root password not set"
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// println "Gradle: Mysql Root Password set to $System.env.HIRS_MYSQL_ROOT_PWD"
|
||||||
|
// }
|
||||||
|
|
||||||
postInstall file('../package/scripts/common/db_create.sh')
|
postInstall file('../package/scripts/common/db_create.sh')
|
||||||
|
// if (System.getenv('HIRS_INSTALL_STATUS').compareTo('fail')==0 ) {
|
||||||
|
// throw new GradleException('MYSQL password error occurred')
|
||||||
|
// }
|
||||||
|
// postInstall 'sh /opt/hirs/scripts/common/db_create.sh'
|
||||||
// postInstall file('../package/scripts/common/ssl_configure.sh')
|
// postInstall file('../package/scripts/common/ssl_configure.sh')
|
||||||
// postInstall 'mkdir -p /etc/hirs/aca/client_files'
|
// postInstall 'mkdir -p /etc/hirs/aca/client_files'
|
||||||
postInstall 'mkdir -p /etc/hirs/aca/certificates'
|
postInstall 'mkdir -p /etc/hirs/aca/certificates'
|
||||||
|
@ -3,35 +3,38 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# HIRS DB creation
|
# HIRS DB creation
|
||||||
# Environment variables used:
|
# Environment variables used:
|
||||||
# a. HIRS_MYSQL_ROOT_EXSITING_PWD: set this variable if mysql root password is already set
|
# a. HIRS_MYSQL_ROOT_PWD: Set this variable if mysql root password is already set
|
||||||
# b. HIRS_MYSQL_ROOT_PWD: set this variable if mysql root password is already set
|
# b. HIRS_DB_PWD: Set the pwd if default password to hirs_db user needs to be changed
|
||||||
# c. HIRS_DB_PWD: Set the pwd if default password to hirs_db user needs to be changed
|
|
||||||
# HIRS_MYSQL_ROOT_NEW_PWD wil be ignored if HIRS_MYSQL_ROOT_EXSITING_PWD is set.
|
# HIRS_MYSQL_ROOT_NEW_PWD wil be ignored if HIRS_MYSQL_ROOT_EXSITING_PWD is set.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Set Mysql root password
|
# Set Mysql HIRS DB password
|
||||||
if [ ! -z $HIRS_MYSQL_ROOT_EXSITING_PWD ]; then
|
|
||||||
HIRS_MYSQL_ROOT_PWD=$HIRS_MYSQL_ROOT_EXSITING_PWD
|
|
||||||
elif [ ! -z $HIRS_MYSQL_ROOT_NEW_PWD ]; then
|
|
||||||
HIRS_MYSQL_ROOT_PWD=$HIRS_MYSQL_ROOT_NEW_PWD
|
|
||||||
else #assume root pasword needs to be set
|
|
||||||
HIRS_MYSQL_ROOT_PWD="root"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $HIRS_DB_PWD ]; then
|
if [ -z $HIRS_DB_PWD ]; then
|
||||||
HIRS_DB_PWD="hirs_db"
|
HIRS_DB_PWD="hirs_db"
|
||||||
fi
|
fi
|
||||||
|
# Save hirs_db mysql user password to the properties file
|
||||||
|
echo "hibernate.connection.username="hirs_db"" > /etc/hirs/hibernate.properties
|
||||||
|
echo "hibernate.connection.password=$HIRS_DB_PWD" >> /etc/hirs/hibernate.properties
|
||||||
|
|
||||||
# Set root password if not set
|
# Test the root password, error if the password doesnt work
|
||||||
|
|
||||||
if mysql -u root -e 'quit' &> /dev/null; then
|
if [ -z ${HIRS_MYSQL_ROOT_PWD} ]; then
|
||||||
echo "Setting root password"
|
echo "HIRS_MYSQL_ROOT_PWD environment variable not set"
|
||||||
mysqladmin -u root --silent password $HIRS_MYSQL_ROOT_PWD || true > /dev/null 2>&1
|
mysql -fu root -e 'quit' &> /dev/null;
|
||||||
|
else
|
||||||
|
echo "Using $HIRS_MYSQL_ROOT_PWD as the mysql root password"
|
||||||
|
$(mysql -u root -p$HIRS_MYSQL_ROOT_PWD -e 'quit' &> /dev/null);
|
||||||
|
fi
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "root password verified"
|
||||||
|
else
|
||||||
|
echo "MYSQL root password was not the default, not supplied, or was incorrect"
|
||||||
|
echo " please set the HIRS_MYSQL_ROOT_PWD system variable and retry."
|
||||||
|
echo " ********** ACA Mysql setup aborted ********" ;
|
||||||
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "HIRS_DB_PWD is $HIRS_DB_PWD"
|
echo "HIRS_DB_PWD is $HIRS_DB_PWD"
|
||||||
echo "HIRS_MYSQL_ROOT_EXSITING_PWD is $HIRS_MYSQL_ROOT_EXSITING_PWD"
|
|
||||||
echo "HIRS_MYSQL_ROOT_NEW_PWD is $HIRS_MYSQL_ROOT_NEW_PWD"
|
|
||||||
echo "HIRS_MYSQL_ROOT_PWD is $HIRS_MYSQL_ROOT_PWD"
|
echo "HIRS_MYSQL_ROOT_PWD is $HIRS_MYSQL_ROOT_PWD"
|
||||||
|
|
||||||
# Check if we're in a Docker container
|
# Check if we're in a Docker container
|
||||||
@ -54,7 +57,6 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
|||||||
chown -R mysql:mysql /var/lib/mysql/
|
chown -R mysql:mysql /var/lib/mysql/
|
||||||
fi
|
fi
|
||||||
echo "Starting mysql...."
|
echo "Starting mysql...."
|
||||||
#nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
|
|
||||||
chown -R mysql:mysql /var/log/mariadb
|
chown -R mysql:mysql /var/log/mariadb
|
||||||
/usr/bin/mysqld_safe &
|
/usr/bin/mysqld_safe &
|
||||||
else
|
else
|
||||||
@ -75,3 +77,4 @@ echo "Creating HIRS Database..."
|
|||||||
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD < /opt/hirs/scripts/common/db_create.sql
|
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD < /opt/hirs/scripts/common/db_create.sql
|
||||||
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD < /opt/hirs/scripts/common/secure_mysql.sql
|
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD < /opt/hirs/scripts/common/secure_mysql.sql
|
||||||
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD -e "ALTER USER 'hirs_db'@'localhost' IDENTIFIED BY '"$HIRS_DB_PWD"'; FLUSH PRIVILEGES;";
|
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD -e "ALTER USER 'hirs_db'@'localhost' IDENTIFIED BY '"$HIRS_DB_PWD"'; FLUSH PRIVILEGES;";
|
||||||
|
|
||||||
|
@ -1,20 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Get the current password from the perstence.properties file
|
echo "dropping hirs database"
|
||||||
#file="/etc/hirs/persistence.properties"
|
|
||||||
# Change java key/value pairs into valid bash key/value pairs
|
|
||||||
#function prop {
|
|
||||||
# grep "${1}" ${file} | cut -d'=' -f2 | xargs
|
|
||||||
#}
|
|
||||||
|
|
||||||
#user="root"
|
|
||||||
# user=$(prop 'persistence.db.user')
|
|
||||||
#pwd=$(prop 'persistence.db.password')
|
|
||||||
pwd="root"
|
|
||||||
|
|
||||||
# Need to update when password get written to the persitence fil
|
|
||||||
# delete the database
|
|
||||||
|
|
||||||
if pgrep mysqld >/dev/null 2>&1; then
|
if pgrep mysqld >/dev/null 2>&1; then
|
||||||
mysql -u "$user" --password="$pwd" < /opt/hirs/scripts/common/db_drop.sql
|
if [ -z ${HIRS_MYSQL_ROOT_PWD} ]; then
|
||||||
|
mysql -u "root" < /opt/hirs/scripts/common/db_drop.sql
|
||||||
|
else
|
||||||
|
mysql -u "root" -p$HIRS_MYSQL_ROOT_PWD < /opt/hirs/scripts/common/db_drop.sq1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
|
|
||||||
DELETE FROM mysql.user WHERE User='';
|
DELETE FROM mysql.user WHERE User='';
|
||||||
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
|
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
|
||||||
DROP DATABASE IF EXISTS test;
|
DROP DATABASE IF EXISTS test;
|
||||||
|
Loading…
Reference in New Issue
Block a user