Some initial changes to the rpm scripts

This commit is contained in:
Cyrus 2022-09-06 08:02:00 -04:00
parent 0e9fd56842
commit 41bd22cbce
5 changed files with 57 additions and 56 deletions

View File

@ -133,12 +133,12 @@ Group : System Environment/Base
%if 0%{?build6}
Requires : mysql-server, openssl, tomcat6, java-1.8.0, rpmdevtools, coreutils, initscripts, chkconfig, sed, grep, iptables
Prefix : /usr/share/tomcat6
Prefix : /opt/tomcat6
%endif
%if 0%{?build7}
Requires : mariadb-server, openssl, tomcat, java-1.8.0, rpmdevtools, coreutils, initscripts, chkconfig, sed, grep, firewalld, policycoreutils
Prefix : /usr/share/tomcat
Prefix : /opt/tomcat
%endif
%description -n HIRS_AttestationCA

View File

@ -60,14 +60,14 @@ cp ${CA_KEYSTORE} /etc/hirs/aca/client-files/
# start up the tomcat service
# Guess where Tomcat is installed and what it's called:
if [ -d /usr/share/tomcat6 ] ; then
TOMCAT_SERVICE=tomcat6
elif [ -d /usr/share/tomcat ] ; then
#if [ -d /usr/share/tomcat6 ] ; then
# TOMCAT_SERVICE=tomcat6
#elif [ -d /usr/share/tomcat ] ; then
TOMCAT_SERVICE=tomcat
else
echo "Can't find Tomcat installation"
exit 1
fi
#else
# echo "Can't find Tomcat installation"
# exit 1
#fi
# restart tomcat after updating the trust store.
if [ $DOCKER_CONTAINER = true ]; then

View File

@ -1,15 +1,15 @@
#!/bin/bash
# Check if we're in a Docker container
if [ -f /.dockerenv ]; then
#if [ -f /.dockerenv ]; then
DOCKER_CONTAINER=true
else
DOCKER_CONTAINER=false
fi
#else
# DOCKER_CONTAINER=false
#fi
echo "Creating HIRS Database..."
if [ $DOCKER_CONTAINER = true ]; then
#if [ $DOCKER_CONTAINER = true ]; then
# If in Docker container, avoid services that invoke the D-Bus
if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
/usr/libexec/mariadb-prepare-db-dir
@ -17,24 +17,24 @@ if [ $DOCKER_CONTAINER = true ]; then
MYSQLD_PID=$(pgrep -u mysql mysqld)
/usr/libexec/mariadb-wait-ready $MYSQLD_PID
fi
else
SQL_SERVICE=`/opt/hirs/scripts/common/get_db_service.sh`
chkconfig $SQL_SERVICE on
service $SQL_SERVICE start
fi
#else
# SQL_SERVICE=`mariadb`#`/opt/hirs/scripts/common/get_db_service.sh`
# chkconfig $SQL_SERVICE on
# service $SQL_SERVICE start
#fi
if [[ -f /etc/redhat-release ]] ; then
CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh`
elif [[ -f /etc/os-release ]] ; then
AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh`
fi
if [ $CENTOS_VER -eq "6" ] ; then
DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el6
elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then
#if [[ -f /etc/redhat-release ]] ; then
# CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh`
#elif [[ -f /etc/os-release ]] ; then
# AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh`
#fi
#if [ $CENTOS_VER -eq "6" ] ; then
# DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el6
#elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then
DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el7
else
echo "Unsupported Linux detected"
exit 1
fi
#else
# echo "Unsupported Linux detected"
# exit 1
#fi
mysql -u root < $DB_CREATE_SCRIPT

View File

@ -9,18 +9,18 @@ elif [[ -f /etc/os-release ]] ; then
AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh`
fi
if [ $CENTOS_VER -eq "6" ] ; then
checkHTTPS=`iptables-save | grep -- "--dport 8443 -j ACCEPT"`
if [[ $checkHTTPS == "" ]]; then
echo "Tomcat HTTPS firewall rule doesn't exist, adding now"
iptables -I INPUT 1 -p tcp -m tcp --dport 8443 -j ACCEPT
service iptables save
fi
elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then
#if [ $CENTOS_VER -eq "6" ] ; then
# checkHTTPS=`iptables-save | grep -- "--dport 8443 -j ACCEPT"`
# if [[ $checkHTTPS == "" ]]; then
# echo "Tomcat HTTPS firewall rule doesn't exist, adding now"
#iptables -I INPUT 1 -p tcp -m tcp --dport 8443 -j ACCEPT
# service iptables save
# fi
#elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then
firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 -p tcp --dport 8443 -j ACCEPT
firewall-cmd --reload
else
echo "Unsupported Linux detected"
exit 1
fi
#else
# echo "Unsupported Linux detected"
# exit 1
#fi

View File

@ -23,7 +23,7 @@ fi
#################
# Key Generation
#################
#################d
# if the CA PEM file does not exist, generate the HIRS CA file and associated keystore and truststores
if ! [ -f $CA_PEM ]; then
@ -96,18 +96,18 @@ if [[ $1 = "server" ]]; then
TOMCAT_MAJOR_VERSION=`echo $TOMCAT_VERSION | head -c 1`
if [[ $TOMCAT_MAJOR_VERSION = '6' ]]; then
CATALINA_HOME=/usr/share/tomcat6
TOMCAT_SERVICE=tomcat6
TOMCAT_CONF=${CATALINA_HOME}/conf/tomcat6.conf
elif [[ $TOMCAT_MAJOR_VERSION = '7' ]] ; then
CATALINA_HOME=/usr/share/tomcat
# if [[ $TOMCAT_MAJOR_VERSION = '6' ]]; then
# CATALINA_HOME=/usr/share/tomcat6
# TOMCAT_SERVICE=tomcat6
# TOMCAT_CONF=${CATALINA_HOME}/conf/tomcat6.conf
# elif [[ $TOMCAT_MAJOR_VERSION = '7' ]] ; then
CATALINA_HOME=/opt/tomcat
TOMCAT_SERVICE=tomcat
TOMCAT_CONF=${CATALINA_HOME}/conf/tomcat.conf
else
echo "Unsupported Tomcat version: ${TOMCAT_MAJOR_VERSION}"
exit 1
fi
# else
# echo "Unsupported Tomcat version: ${TOMCAT_MAJOR_VERSION}"
# exit 1
# fi
if [[ -z `grep -o "keystoreFile=\"${CA_CERT_DIR_ESCAPED}\/keyStore.jks\"" $CATALINA_HOME/conf/server.xml` ]]; then
echo "Configuring Tomcat SSL"
@ -124,7 +124,7 @@ if [[ $1 = "server" ]]; then
# Configure the server.xml file such that it uses our key store and trust store
if [ $DOCKER_CONTAINER = true ]; then
# If in Docker container, avoid services that invoke the D-Bus
if [[ $(pgrep -c -f /usr/share/tomcat) -ne 0 ]]; then
if [[ $(pgrep -c -f /opt/tomcat) -ne 0 ]]; then
echo "Tomcat is running, so we stop it."
/usr/libexec/tomcat/server stop
fi
@ -160,7 +160,8 @@ EOF
if [ $DOCKER_CONTAINER = true ]; then
# If in Docker container, avoid services that invoke the D-Bus
(/usr/libexec/tomcat/server start) &
#(/usr/libexec/tomcat/server start) &
(/opt/tomcat/bin/catalina.sh start) &
# Wait for Tomcat to boot completely
until [ "`curl --silent --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ]; do
: