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
|
DOCKER_CONTAINER=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating HIRS Database..."
|
|
||||||
|
|
||||||
# Check if mysql is already running, if not initialize
|
# Check if mysql is already running, if not initialize
|
||||||
if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
||||||
# Check if running in a container
|
# 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
|
if [ -e /run/dbus/messagebus.pid ]; then
|
||||||
rm /run/dbus/messagebus.pid
|
rm /run/dbus/messagebus.pid
|
||||||
fi
|
fi
|
||||||
echo "starting dbus";
|
echo "Starting dbus";
|
||||||
dbus-daemon --fork --system
|
dbus-daemon --fork --system
|
||||||
fi
|
fi
|
||||||
# Check if mariadb is setup
|
# Check if mariadb is setup
|
||||||
@ -51,10 +49,10 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
|
|||||||
echo "Installing mariadb"
|
echo "Installing mariadb"
|
||||||
/usr/bin/mysql_install_db
|
/usr/bin/mysql_install_db
|
||||||
chown -R mysql:mysql /var/lib/mysql/
|
chown -R mysql:mysql /var/lib/mysql/
|
||||||
chown -R mysql:mysql /var/log/mariadb/
|
|
||||||
fi
|
fi
|
||||||
echo "Starting mysql...."
|
echo "Starting mysql...."
|
||||||
#nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
|
#nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
|
||||||
|
chown -R mysql:mysql /var/log/mariadb
|
||||||
/usr/bin/mysqld_safe &
|
/usr/bin/mysqld_safe &
|
||||||
else
|
else
|
||||||
SQL_SERVICE=`/opt/hirs/scripts/common/get_db_service.sh`
|
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.
|
# Wait for mysql to start before continuing. Exit if it doesnt start.
|
||||||
count=0;
|
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;
|
sleep 1;
|
||||||
count=$((count+1));
|
count=$((count+1));
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$count" -gt 4 ]; then
|
if [ "$count" -gt 99 ]; then
|
||||||
echo "Mysql failed to start"
|
echo "Mysql failed to start"
|
||||||
exit 1;
|
exit 1;
|
||||||
else
|
else
|
||||||
echo "mysql is started"
|
echo "Mysql is runnning"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set intial password, ingore result in case its already been set
|
# 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
|
mysqladmin -u root --silent password $DB_DEFAULT_PWD || true > /dev/null 2>&1
|
||||||
|
|
||||||
# Create the hirs_db database
|
# Create the hirs_db database
|
||||||
|
echo "Creating HIRS 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,11 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
tom_version="10.1.1"
|
tom_version="10.1.1"
|
||||||
|
tom_maj=$(echo "$tom_version" | cut -d '.' -f 1)
|
||||||
CATALINA_HOME=/opt/tomcat/
|
CATALINA_HOME=/opt/tomcat/
|
||||||
CATALINA_BASE=/opt/tomcat/
|
CATALINA_BASE=/opt/tomcat/
|
||||||
|
|
||||||
export CATALINA_HOME
|
|
||||||
export CATALINA_BASE
|
|
||||||
|
|
||||||
# Check if tomcat already installed
|
# Check if tomcat already installed
|
||||||
if [ -d "/opt/tomcat" ]; then
|
if [ -d "/opt/tomcat" ]; then
|
||||||
echo "tomcat already installed"
|
echo "tomcat already installed"
|
||||||
@ -14,7 +12,7 @@ else
|
|||||||
pushd /tmp
|
pushd /tmp
|
||||||
useradd -r -d /opt/tomcat/ -s /bin/false -c "Tomcat User" tomcat
|
useradd -r -d /opt/tomcat/ -s /bin/false -c "Tomcat User" tomcat
|
||||||
dnf install wget -y
|
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
|
mkdir /opt/tomcat
|
||||||
tar -xzf apache-tomcat-$tom_version.tar.gz -C /opt/tomcat --strip-components=1
|
tar -xzf apache-tomcat-$tom_version.tar.gz -C /opt/tomcat --strip-components=1
|
||||||
rm apache-tomcat-$tom_version.tar.gz
|
rm apache-tomcat-$tom_version.tar.gz
|
||||||
@ -31,5 +29,7 @@ else
|
|||||||
systemctl start tomcat
|
systemctl start tomcat
|
||||||
systemctl enable tomcat
|
systemctl enable tomcat
|
||||||
fi
|
fi
|
||||||
firewall-cmd --add-port=8080/tcp --permanent
|
if [ $(pgrep -c FirewallD) == "1" ]; then
|
||||||
firewall-cmd --add-port=8443/tcp --permanent
|
firewall-cmd --add-port=8080/tcp --permanent
|
||||||
|
firewall-cmd --add-port=8443/tcp --permanent
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user