updated db create [no ci]

This commit is contained in:
iadgovuser26 iadgovuser26@empire.eclipse.ncsc.mil 2023-01-23 21:35:27 +00:00
parent 8215da5b76
commit 3dda6855ff

View File

@ -30,23 +30,23 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
if [ $DOCKER_CONTAINER = true ]; then
# if in Docker container, avoid services that invoke the D-Bus
echo "ACA is running in a container..."
# Start DBus
mkdir -p /var/run/dbus
if [ -e /var/run/dbus/pid ]; then
rm /var/run/dbus/pid
fi
if [ -e /var/run/dbus/system_bus_socket ]; then
rm /var/run/dbus/system_bus_socket
fi
if [ -e /run/dbus/messagebus.pid ]; then
rm /run/dbus/messagebus.pid
fi
if pgrep dbus ;
then echo "dbus already running";
else
echo "starting dbus";
dbus-daemon --fork --system
# Check is Dbus is running
if [[ $(pgrep -c -u dbus dbus) -eq 0 ]]; then
# Start DBus
mkdir -p /var/run/dbus
if [ -e /var/run/dbus/pid ]; then
rm /var/run/dbus/pid
fi
if [ -e /var/run/dbus/system_bus_socket ]; then
rm /var/run/dbus/system_bus_socket
fi
if [ -e /run/dbus/messagebus.pid ]; then
rm /run/dbus/messagebus.pid
fi
echo "starting dbus";
dbus-daemon --fork --system
fi
# Check if mariadb is setup
if [ ! -d "/var/lib/mysql/mysql/" ]; then
echo "Installing mariadb"
/usr/bin/mysql_install_db
@ -54,7 +54,8 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then
chown -R mysql:mysql /var/log/mariadb/
fi
echo "Starting mysql...."
nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
#nohup /usr/bin/mysqld_safe > /dev/null 2>&1 &
/usr/bin/mysqld_safe &
else
SQL_SERVICE=`/opt/hirs/scripts/common/get_db_service.sh`
systemctl $SQL_SERVICE enable
@ -64,14 +65,16 @@ 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) -eq 0 ] && [ "$count" -lt 5 ]); do
sleep 1;
count=$(count+1);
count=$((count+1));
done
if [ $count -gt 5 ]; then
if [ "$count" -gt 4 ]; then
echo "Mysql failed to start"
exit 1;
else
echo "mysql is started"
fi
# Set intial password, ingore result in case its already been set