Skip to content

Commit 2f3f36e

Browse files
committed
Science Commit 5.
1 parent cad7925 commit 2f3f36e

4 files changed

Lines changed: 50 additions & 23 deletions

File tree

modules/black/presidential/Brarner.M.Alete/install/deploy-local.sh

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,50 @@ elif ls "$BMA_ROOT/lib/"*.jar &>/dev/null; then
5353
echo "[*] JARs copied from lib/ to WEB-INF/lib/"
5454
fi
5555

56-
# Ensure db.properties exists — prompt if missing
56+
# Ensure db.properties exists — use .nwe-credentials or prompt if interactive
5757
DB_PROPS="$DEPLOY_DIR/WEB-INF/db.properties"
58-
if [ ! -f "$DB_PROPS" ] || ! grep -q "db.password=." "$DB_PROPS" 2>/dev/null; then
59-
echo ""
60-
echo "[*] db.properties needs MySQL credentials for JSP pages."
61-
read -rp " MySQL user [root]: " DB_USER
62-
DB_USER="${DB_USER:-root}"
63-
read -rsp " MySQL password: " DB_PASS
64-
echo ""
65-
read -rp " MySQL host [localhost]: " DB_HOST
66-
DB_HOST="${DB_HOST:-localhost}"
67-
read -rp " MySQL port [3306]: " DB_PORT
68-
DB_PORT="${DB_PORT:-3306}"
69-
cat > "$DB_PROPS" <<EOF
58+
if [ ! -f "$DB_PROPS" ] || ! grep -q "db.password=." "$DB_PROPS" 2>/dev/null || grep -q "CHANGE_ME" "$DB_PROPS" 2>/dev/null; then
59+
# Try .nwe-credentials first (non-interactive safe)
60+
NWE_ROOT="$(cd "$SCRIPT_DIR/../../../.." 2>/dev/null && pwd)"
61+
if [ -f "$NWE_ROOT/.nwe-credentials" ]; then
62+
source "$NWE_ROOT/.nwe-credentials"
63+
mkdir -p "$DEPLOY_DIR/WEB-INF"
64+
cat > "$DB_PROPS" <<EOF
65+
# BMA Database Configuration — auto-generated from .nwe-credentials
66+
db.driver=com.mysql.cj.jdbc.Driver
67+
db.url=jdbc:mysql://${NWE_DB_HOST:-127.0.0.1}:${NWE_DB_PORT:-3306}/BrarnerScience
68+
db.user=${NWE_DB_USER:-root}
69+
db.password=${NWE_DB_PASS}
70+
EOF
71+
chmod 600 "$DB_PROPS"
72+
echo "[*] db.properties generated from .nwe-credentials"
73+
elif [ -t 0 ]; then
74+
# Interactive terminal — prompt for credentials
75+
echo ""
76+
echo "[*] db.properties needs MySQL credentials for JSP pages."
77+
read -rp " MySQL user [root]: " DB_USER
78+
DB_USER="${DB_USER:-root}"
79+
read -rsp " MySQL password: " DB_PASS
80+
echo ""
81+
read -rp " MySQL host [localhost]: " DB_HOST
82+
DB_HOST="${DB_HOST:-localhost}"
83+
read -rp " MySQL port [3306]: " DB_PORT
84+
DB_PORT="${DB_PORT:-3306}"
85+
mkdir -p "$DEPLOY_DIR/WEB-INF"
86+
cat > "$DB_PROPS" <<EOF
7087
# BMA Database Configuration — written by deploy-local.sh
7188
db.driver=com.mysql.cj.jdbc.Driver
7289
db.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/BrarnerScience
7390
db.user=${DB_USER}
7491
db.password=${DB_PASS}
7592
EOF
76-
chmod 600 "$DB_PROPS"
77-
echo "[*] db.properties written"
93+
chmod 600 "$DB_PROPS"
94+
echo "[*] db.properties written"
95+
else
96+
# Non-interactive and no credentials file — skip (don't hang)
97+
echo "[!] db.properties missing and no .nwe-credentials found (non-interactive)"
98+
echo " JSP database pages will fail. Create .nwe-credentials and redeploy."
99+
fi
78100
else
79101
echo "[*] db.properties present (user=$(grep '^db.user=' "$DB_PROPS" | cut -d= -f2-))"
80102
fi
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4695
1+
6495

scripts/web/deploy-all.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,21 @@ for SCRIPT in $ENABLED; do
4141
# Run setup-db if it exists alongside deploy script
4242
SETUP_DB="$(dirname "$FULL_PATH")/setup-db.sh"
4343
if [ -f "$SETUP_DB" ]; then
44-
bash "$SETUP_DB" 2>/dev/null && echo " [DB] $(basename "$(dirname "$SETUP_DB")") database ready" || true
44+
timeout 30 bash "$SETUP_DB" 2>/dev/null && echo " [DB] $(basename "$(dirname "$SETUP_DB")") database ready" || true
4545
fi
4646

4747
if [ -f "$FULL_PATH" ]; then
4848
echo ""
4949
echo "[*] Deploying: $SCRIPT"
50-
if bash "$FULL_PATH" 2>&1 | tail -3; then
50+
if timeout 60 bash "$FULL_PATH" 2>&1 | tail -3; then
5151
PASS=$((PASS + 1))
5252
else
53-
echo "[!] Failed: $SCRIPT"
53+
EXIT_CODE=$?
54+
if [ $EXIT_CODE -eq 124 ]; then
55+
echo "[!] TIMEOUT (60s): $SCRIPT — skipping (may need manual deploy)"
56+
else
57+
echo "[!] Failed: $SCRIPT"
58+
fi
5459
FAIL=$((FAIL + 1))
5560
fi
5661
else
@@ -59,7 +64,7 @@ for SCRIPT in $ENABLED; do
5964
bash "$PROJECT_ROOT/scripts/fix-missing-deploy-scripts.sh" 2>/dev/null
6065
if [ -f "$FULL_PATH" ]; then
6166
echo "[*] Auto-created missing script, deploying: $SCRIPT"
62-
bash "$FULL_PATH" 2>&1 | tail -3 && PASS=$((PASS + 1)) || FAIL=$((FAIL + 1))
67+
timeout 60 bash "$FULL_PATH" 2>&1 | tail -3 && PASS=$((PASS + 1)) || FAIL=$((FAIL + 1))
6368
else
6469
echo "[!] Script not found (nested .git repo?): $FULL_PATH"
6570
FAIL=$((FAIL + 1))

scripts/web/post-clone.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ SETUP_SCRIPTS=(
9191
for SETUP in "${SETUP_SCRIPTS[@]}"; do
9292
FULL="$PROJECT_ROOT/$SETUP"
9393
if [ -f "$FULL" ]; then
94-
bash "$FULL" 2>/dev/null && echo " [OK] $SETUP" || echo " [WARN] $SETUP (MySQL may not be ready)"
94+
timeout 30 bash "$FULL" 2>/dev/null && echo " [OK] $SETUP" || echo " [WARN] $SETUP (timeout or MySQL not ready)"
9595
fi
9696
done
9797

98-
# 6. Deploy all web modules
98+
# 6. Deploy all web modules (60s timeout per module)
9999
echo ""
100-
bash "$SCRIPT_DIR/deploy-all.sh"
100+
timeout 600 bash "$SCRIPT_DIR/deploy-all.sh" || echo "[WARN] deploy-all.sh timed out (10 min) — some modules may need manual deploy"
101101

102102
# 7. Start Tomcat
103103
systemctl start tomcat 2>/dev/null || "$TOMCAT_HOME/bin/startup.sh"

0 commit comments

Comments
 (0)