From 11044f92a56cc27e59a0659b99a8c1bfbb9c15de Mon Sep 17 00:00:00 2001 From: "iadgovuser26 iadgovuser26@empire.eclipse.ncsc.mil" Date: Wed, 25 Jan 2023 20:47:38 +0000 Subject: [PATCH] update mysql check [no ci] --- package/scripts/common/db_create.sh | 30 +++-------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/package/scripts/common/db_create.sh b/package/scripts/common/db_create.sh index e8c49f0a..9f9bb669 100644 --- a/package/scripts/common/db_create.sh +++ b/package/scripts/common/db_create.sh @@ -28,22 +28,6 @@ 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..." - # 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" @@ -61,20 +45,12 @@ if [[ $(pgrep -c -u mysql mysqld) -eq 0 ]]; then fi fi -# Wait for mysql to start before continuing. Exit if it doesnt start. -count=0; -while ([ $(pgrep -c -u mysql mysqld) = "0" ] && [ "$count" -lt 100 ]); do +# Wait for mysql to start before continuing. +echo "Checking mysqld status..." +while ! mysqladmin ping -h "$localhost" --silent; do sleep 1; - count=$((count+1)); done -if [ "$count" -gt 99 ]; then - echo "Mysql failed to start" - exit 1; -else - echo "Mysql is runnning" -fi - # Set intial password, ingore result in case its already been set echo "Setting Mysql password" mysqladmin -u root --silent password $DB_DEFAULT_PWD || true > /dev/null 2>&1