mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-21 13:57:56 +00:00
added check for FirwallD [no ci]
This commit is contained in:
parent
3dda6855ff
commit
e0620c925d
@ -22,8 +22,6 @@ else
|
||||
DOCKER_CONTAINER=false
|
||||
fi
|
||||
|
||||
echo "Creating HIRS Database..."
|
||||
|
||||
# Check if mysql is already running, if not initialize
|
||||
if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
||||
# Check if running in a container
|
||||
@ -43,7 +41,7 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
||||
if [ -e /run/dbus/messagebus.pid ]; then
|
||||
rm /run/dbus/messagebus.pid
|
||||
fi
|
||||
echo "starting dbus";
|
||||
echo "Starting dbus";
|
||||
dbus-daemon --fork --system
|
||||
fi
|
||||
# Check if mariadb is setup
|
||||
@ -51,10 +49,10 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
||||
echo "Installing mariadb"
|
||||
/usr/bin/mysql_install_db
|
||||
chown -R mysql:mysql /var/lib/mysql/
|
||||
chown -R mysql:mysql /var/log/mariadb/
|
||||
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
|
||||
SQL_SERVICE=`/opt/hirs/scripts/common/get_db_service.sh`
|
||||
@ -65,22 +63,23 @@ fi
|
||||
|
||||
# Wait for mysql to start before continuing. Exit if it doesnt start.
|
||||
count=0;
|
||||
while ([ $(pgrep -c -u mysql mysqld) -eq 0 ] && [ "$count" -lt 5 ]); do
|
||||
while ([ $(pgrep -c -u mysql mysqld) = "0" ] && [ "$count" -lt 100 ]); do
|
||||
sleep 1;
|
||||
count=$((count+1));
|
||||
done
|
||||
|
||||
if [ "$count" -gt 4 ]; then
|
||||
if [ "$count" -gt 99 ]; then
|
||||
echo "Mysql failed to start"
|
||||
exit 1;
|
||||
else
|
||||
echo "mysql is started"
|
||||
echo "Mysql is runnning"
|
||||
fi
|
||||
|
||||
# Set intial password, ingore result in case its already been set
|
||||
echo "Setting mysql password"
|
||||
echo "Setting Mysql password"
|
||||
mysqladmin -u root --silent password $DB_DEFAULT_PWD || true > /dev/null 2>&1
|
||||
|
||||
# Create the hirs_db database
|
||||
echo "Creating HIRS Database..."
|
||||
DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el7
|
||||
mysql -u root --password="$DB_DEFAULT_PWD" < $DB_CREATE_SCRIPT
|
||||
|
@ -1,11 +1,9 @@
|
||||
#!/bin/bash
|
||||
tom_version="10.1.1"
|
||||
tom_maj=$(echo "$tom_version" | cut -d '.' -f 1)
|
||||
CATALINA_HOME=/opt/tomcat/
|
||||
CATALINA_BASE=/opt/tomcat/
|
||||
|
||||
export CATALINA_HOME
|
||||
export CATALINA_BASE
|
||||
|
||||
# Check if tomcat already installed
|
||||
if [ -d "/opt/tomcat" ]; then
|
||||
echo "tomcat already installed"
|
||||
@ -14,7 +12,7 @@ else
|
||||
pushd /tmp
|
||||
useradd -r -d /opt/tomcat/ -s /bin/false -c "Tomcat User" tomcat
|
||||
dnf install wget -y
|
||||
wget https://dlcdn.apache.org/tomcat/tomcat-10/v$tom_version/bin/apache-tomcat-10.1.1.tar.gz
|
||||
wget https://dlcdn.apache.org/tomcat/tomcat-$tom_maj/v$tom_version/bin/apache-tomcat-$tom_version.tar.gz
|
||||
mkdir /opt/tomcat
|
||||
tar -xzf apache-tomcat-$tom_version.tar.gz -C /opt/tomcat --strip-components=1
|
||||
rm apache-tomcat-$tom_version.tar.gz
|
||||
@ -31,5 +29,7 @@ else
|
||||
systemctl start tomcat
|
||||
systemctl enable tomcat
|
||||
fi
|
||||
firewall-cmd --add-port=8080/tcp --permanent
|
||||
firewall-cmd --add-port=8443/tcp --permanent
|
||||
if [ $(pgrep -c FirewallD) == "1" ]; then
|
||||
firewall-cmd --add-port=8080/tcp --permanent
|
||||
firewall-cmd --add-port=8443/tcp --permanent
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user