Skip to content

Commit 7c24573

Browse files
committed
Science Commit 5.
1 parent a215528 commit 7c24573

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

scripts/web/post-clone.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ echo "[OK] Firewall configured"
124124
# 5.5. Setup module databases (safe — uses CREATE IF NOT EXISTS, never drops)
125125
echo ""
126126
echo "[*] Setting up module databases (non-destructive — existing data preserved)..."
127+
128+
# Wait for MySQL to be fully ready before running setup scripts
129+
echo "[*] Waiting for MySQL to accept connections..."
130+
for i in $(seq 1 30); do
131+
if mysql -u "$NWE_DB_USER" -p"$NWE_DB_PASS" -h "${NWE_DB_HOST:-127.0.0.1}" -P "${NWE_DB_PORT:-3306}" -e "SELECT 1" &>/dev/null; then
132+
echo "[OK] MySQL is ready (attempt $i)"
133+
break
134+
fi
135+
if [ "$i" -eq 30 ]; then
136+
echo "[ERROR] MySQL did not become ready within 30 seconds. Skipping database setup."
137+
echo " Run manually: bash scripts/web/setup-all-databases.sh"
138+
fi
139+
sleep 1
140+
done
127141
echo ""
128142
echo " ┌─────────────────────────────────────────────────────────────"
129143
echo " │ Database Module"
@@ -146,6 +160,9 @@ echo " │ BrarnerScience Brarner.M.Alete"
146160
echo " └─────────────────────────────────────────────────────────────"
147161
echo ""
148162

163+
# Export MYSQL_PWD so child setup scripts can connect without -p on command line
164+
export MYSQL_PWD="$NWE_DB_PASS"
165+
149166
SETUP_SCRIPTS=(
150167
"modules/fbi/servlets/setup-db.sh"
151168
"modules/cia/servlets/setup-db.sh"
@@ -163,6 +180,8 @@ for SETUP in "${SETUP_SCRIPTS[@]}"; do
163180
fi
164181
done
165182

183+
unset MYSQL_PWD
184+
166185
# 6. Deploy all web modules (30s timeout per module, inline for reliability)
167186
echo ""
168187
echo "[*] Deploying all web modules (30s timeout each)..."

0 commit comments

Comments
 (0)