cleaned up dnf install and dnf remove

This commit is contained in:
iadgovuser26 2023-05-03 16:54:35 +00:00 committed by iadgovuser26 iadgovuser26@empire.eclipse.ncsc.mil
parent 5330318439
commit b5c4d86430
5 changed files with 48 additions and 40 deletions

View File

@ -75,7 +75,7 @@ ospackage {
addParentDirs = true
createDirectoryEntry true
preInstall "rm -rf /opt/hirs/default-properties"
preInstall "rm -rf /opt/hirs/default-properties"
preInstall "mkdir -p /opt/hirs/default-properties/"
preInstall "mkdir -p /tmp/hirs/default-properties/"
@ -120,7 +120,22 @@ ospackage {
from '../HIRS_AttestationCA/src/main/resources/component-class.json'
}
// Post Install
postInstall file('../package/scripts/common/db_create.sh')
// 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')
// 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 'mkdir -p /etc/hirs/aca/client_files'
postInstall 'mkdir -p /etc/hirs/aca/certificates'

View File

@ -3,35 +3,38 @@
###############################################################################
# HIRS DB creation
# Environment variables used:
# a. HIRS_MYSQL_ROOT_EXSITING_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
# c. HIRS_DB_PWD: Set the pwd if default password to hirs_db user needs to be changed
# a. 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
# HIRS_MYSQL_ROOT_NEW_PWD wil be ignored if HIRS_MYSQL_ROOT_EXSITING_PWD is set.
################################################################################
# Set Mysql root 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
# Set Mysql HIRS DB password
if [ -z $HIRS_DB_PWD ]; then
HIRS_DB_PWD="hirs_db"
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
echo "Setting root password"
mysqladmin -u root --silent password $HIRS_MYSQL_ROOT_PWD || true > /dev/null 2>&1
if [ -z ${HIRS_MYSQL_ROOT_PWD} ]; then
echo "HIRS_MYSQL_ROOT_PWD environment variable not set"
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
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"
# 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/
fi
echo "Starting mysql...."
#nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
chown -R mysql:mysql /var/log/mariadb
/usr/bin/mysqld_safe &
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/secure_mysql.sql
mysql -u root --password=$HIRS_MYSQL_ROOT_PWD -e "ALTER USER 'hirs_db'@'localhost' IDENTIFIED BY '"$HIRS_DB_PWD"'; FLUSH PRIVILEGES;";

View File

@ -1,2 +1,2 @@
CREATE DATABASE IF NOT EXISTS `hirs_db` CHARACTER SET = 'utf8mb4' COLLATE = 'utf8mb4_general_ci';
GRANT ALL ON hirs_db.* TO "hirs_db"@"localhost" IDENTIFIED BY "$HIRS_DB_PWD";
GRANT ALL ON hirs_db.* TO "hirs_db"@"localhost" IDENTIFIED BY "$HIRS_DB_PWD";

View File

@ -1,20 +1,11 @@
#!/bin/bash
# Get the current password from the perstence.properties file
#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
#}
echo "dropping hirs database"
#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
mysql -u "$user" --password="$pwd" < /opt/hirs/scripts/common/db_drop.sql
if pgrep mysqld >/dev/null 2>&1; then
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

View File

@ -1,6 +1,5 @@
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES
FLUSH PRIVILEGES