mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-31 16:35:29 +00:00
Added scripts to upgrade hirs_db schema according to package upgrade. At the time of writing
there are schema changes when upgrading from 1.0.3 to 1.0.4 but not when upgrading to 1.1.0. These scripts are called when 'yum upgrade HIRS_AttestationCA' is invoked. Fixed script file path Fixed MySQL syntax error These changes now differentiate between upgrade versions and add respective columns, and also account for upgrades from 1.0.3 directly to 1.1.0.
This commit is contained in:
parent
6a59033768
commit
b140ab46e9
@ -160,7 +160,7 @@ mkdir -p /opt/hirs/scripts/common/
|
||||
cp -f /opt/hirs/scripts/common/aca/* /opt/hirs/scripts/common/
|
||||
|
||||
# run these only on a fresh install of the package
|
||||
if [ "$1" = "1" ]; then
|
||||
if [ $1 == 1 ]; then
|
||||
# open necessary ports
|
||||
sh /opt/hirs/scripts/common/firewall_configure_tomcat.sh
|
||||
|
||||
@ -178,11 +178,31 @@ if [ "$1" = "1" ]; then
|
||||
sh /opt/hirs/scripts/common/db_create.sh
|
||||
fi
|
||||
|
||||
# modify mysql schema accordingly on upgrade
|
||||
if [ $1 -gt 1 ]; then
|
||||
echo "Upgrading hirs_db schema!"
|
||||
if [ %{version} == "1.0.4" ]; then
|
||||
if (mysql -u root hirs_db < /opt/hirs/scripts/common/upgrade_schema_1.0.4.sql); then
|
||||
echo "Upgrade to version 1.0.4"
|
||||
else
|
||||
echo "Error upgrading HIRS database schema to 1.0.4!"
|
||||
exit 1;
|
||||
fi
|
||||
elif [ %{version} == "1.1.0" ]; then
|
||||
if (mysql -u root hirs_db < /opt/hirs/scripts/common/upgrade_schema_1.0.4.sql && mysql -u root hirs_db < /opt/hirs/scripts/common/upgrade_schema_1.1.0.sql); then
|
||||
echo "Upgrade to version 1.1.0"
|
||||
else
|
||||
echo "Error upgrading HIRS database schema to 1.1.0!"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
sh /opt/hirs/scripts/aca/certificate_generate.sh
|
||||
|
||||
%preun -n HIRS_AttestationCA
|
||||
# don't run these during an upgrade
|
||||
if [ "$1" = "0" ]; then
|
||||
if [ $1 == 0 ]; then
|
||||
# if the Server isn't installed, deconfigure Tomcat and MySQL SSL and drop the database
|
||||
if [[ -z `rpm -qa HIRS_Server` ]]; then
|
||||
echo 'Restoring Tomcat and MySQL configuration'
|
||||
@ -195,7 +215,7 @@ fi
|
||||
|
||||
%postun -n HIRS_AttestationCA
|
||||
# don't run these during an upgrade
|
||||
if [ "$1" = "0" ]; then
|
||||
if [ $1 == 0 ]; then
|
||||
# Removes WARS from the Tomcat installation as well as ACA configuration files and certificates
|
||||
# (/etc/hirs/aca), and ACA installation (/opt/hirs/attestation-ca). Do not run during an upgrade
|
||||
rm -f %{prefix}/webapps/HIRS_AttestationCA*.war
|
||||
|
30
package/scripts/common/upgrade_schema_1.0.4.sql
Normal file
30
package/scripts/common/upgrade_schema_1.0.4.sql
Normal file
@ -0,0 +1,30 @@
|
||||
DROP PROCEDURE IF EXISTS upgrade_schema_to_1_0_4;
|
||||
DELIMITER '//'
|
||||
|
||||
CREATE PROCEDURE upgrade_schema_to_1_0_4()
|
||||
BEGIN
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='Certificate' AND COLUMN_NAME='isDeltaChain')) THEN
|
||||
ALTER TABLE Certificate ADD isDeltaChain bit(1) DEFAULT NULL;
|
||||
END IF;
|
||||
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='Certificate' AND COLUMN_NAME='platformBase')) THEN
|
||||
ALTER TABLE Certificate ADD platformBase bit(1) DEFAULT NULL;
|
||||
END IF;
|
||||
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='Certificate' AND COLUMN_NAME='platformChainType')) THEN
|
||||
ALTER TABLE Certificate ADD platformChainType varchar(255) DEFAULT NULL;
|
||||
END IF;
|
||||
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='SupplyChainValidationSummary' AND COLUMN_NAME='message')) THEN
|
||||
ALTER TABLE SupplyChainValidationSummary ADD message longtext;
|
||||
END IF;
|
||||
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='TPMReport' AND COLUMN_NAME='rawQuote')) THEN
|
||||
ALTER TABLE TPMReport ADD rawQuote blob;
|
||||
END IF;
|
||||
END//
|
||||
DELIMITER ';'
|
||||
|
||||
CALL upgrade_schema_to_1_0_4;
|
||||
DROP PROCEDURE upgrade_schema_to_1_0_4;
|
||||
|
16
package/scripts/common/upgrade_schema_1.1.0.sql
Normal file
16
package/scripts/common/upgrade_schema_1.1.0.sql
Normal file
@ -0,0 +1,16 @@
|
||||
#commands here if there are schema changes in 1.1.0
|
||||
DROP PROCEDURE IF EXISTS upgrade_schema_to_1_1_0;
|
||||
DELIMITER '//'
|
||||
|
||||
CREATE PROCEDURE upgrade_schema_to_1_1_0()
|
||||
BEGIN
|
||||
IF(NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='hirs_db' AND TABLE_NAME='Certificate' AND COLUMN_NAME='componentFailures')) THEN
|
||||
ALTER TABLE Certificate ADD componentFailures varchar(255) DEFAULT NULL;
|
||||
END IF;
|
||||
|
||||
END//
|
||||
DELIMITER ';'
|
||||
|
||||
CALL upgrade_schema_to_1_1_0;
|
||||
DROP PROCEDURE upgrade_schema_to_1_1_0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user