mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-18 02:39:56 +00:00
updated db_drop script [no ci]
This commit is contained in:
parent
eae9e37228
commit
84ac9e43a6
@ -159,8 +159,7 @@ ospackage {
|
|||||||
// Copy files to /tmp that package manager will be expecting them there
|
// Copy files to /tmp that package manager will be expecting them there
|
||||||
preUninstall 'mkdir -p /tmp/aca/default-properties/'
|
preUninstall 'mkdir -p /tmp/aca/default-properties/'
|
||||||
preUninstall 'cp /opt/hirs/default-properties/* /tmp/aca/default-properties/.'
|
preUninstall 'cp /opt/hirs/default-properties/* /tmp/aca/default-properties/.'
|
||||||
// postUninstall file(/opt/hirs/scripts/common/db_drop.sql)
|
preUninstall file('../package/scripts/common/db_drop.sh')
|
||||||
|
|
||||||
|
|
||||||
buildRpm.dependsOn ':HIRS_AttestationCA:war'
|
buildRpm.dependsOn ':HIRS_AttestationCA:war'
|
||||||
|
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DB_DEFAULT_PWD="hirs_db"
|
#
|
||||||
|
###############################################
|
||||||
|
# HIRS DB creation
|
||||||
|
# Conditions to address
|
||||||
|
# a. Install is called mutiple times
|
||||||
|
# b. Another app sets the root password
|
||||||
|
# c. ACA is updated
|
||||||
|
# d. ACA is updated after a DB password change
|
||||||
|
################################################
|
||||||
|
|
||||||
|
if [ -z ${HIRS_DB_PWD+x} ]; then
|
||||||
|
DB_DEFAULT_PWD="hirs_db";
|
||||||
|
else
|
||||||
|
DB_DEFAULT_PWD=$HIRS_DB_PWD;
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if we're in a Docker container
|
# Check if we're in a Docker container
|
||||||
if [ -f /.dockerenv ]; then
|
if [ -f /.dockerenv ]; then
|
||||||
@ -25,10 +39,11 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
|||||||
systemctl $SQL_SERVICE enable
|
systemctl $SQL_SERVICE enable
|
||||||
systemctl $SQL_SERVICE start
|
systemctl $SQL_SERVICE start
|
||||||
fi
|
fi
|
||||||
# Set intial password
|
|
||||||
mysqladmin -u root password $DB_DEFAULT_PWD
|
|
||||||
fi
|
fi
|
||||||
# Initialize the hirs_db database
|
|
||||||
|
|
||||||
|
# Set intial passwor, ingore result in case its already been set
|
||||||
|
mysqladmin -u root --silent password $DB_DEFAULT_PWD || true > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Create the hirs_db database
|
||||||
DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el7
|
DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el7
|
||||||
mysql -u root --password="$DB_DEFAULT_PWD" < $DB_CREATE_SCRIPT
|
mysql -u root --password="$DB_DEFAULT_PWD" < $DB_CREATE_SCRIPT
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
|
|
||||||
# delete the database
|
# Get the current password from the perstence.properties file
|
||||||
mysql -u root < /opt/hirs/scripts/common/db_drop.sql
|
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')
|
||||||
|
|
||||||
|
# drop the database
|
||||||
|
mysql -u "$user" --password="$pwd" < /opt/hirs/scripts/common/db_drop.sql
|
||||||
|
Loading…
Reference in New Issue
Block a user