Skip to content

Commit f190172

Browse files
committed
Update triage, leverage drush instead of MySQL show
1 parent 99d40be commit f190172

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

build/scripts/pre-init.d/57_triage_build.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
rm -rf /tmp/DRUPAL_DB_LIVE
66
rm -rf /tmp/DRUPAL_FILES_LIVE
77

8-
# Check if the database has tables named *node*. If so, this is likely a live DB.
9-
RESULT=$(mysqlshow -h "$MYSQL_HOSTNAME" -P "$MYSQL_PORT" --user="${DRUPAL_SITE_ID}_user" --password="$DRUPAL_DB_PASSWORD" --skip-ssl "${DRUPAL_SITE_ID}_db" | grep node)
10-
if [ ! -z "$RESULT" ]; then
11-
touch /tmp/DRUPAL_DB_LIVE
12-
echo "Triage : Found Drupal Database."
8+
# Determine if the site was previously built by checking for both .htaccess and settings.php in the public file dir.
9+
if [ -f "$DRUPAL_ROOT/sites/default/files/.htaccess" ] && [ -f "$DRUPAL_ROOT/sites/default/files/settings.php" ]; then
10+
touch /tmp/DRUPAL_FILES_LIVE
11+
echo "Triage : Found Drupal Filesystem and settings.php."
1312
fi
1413

15-
# Determine if the site was previously built by checking the public file dir.
16-
if [ -f "$DRUPAL_ROOT/sites/default/files/.htaccess" ]; then
17-
touch /tmp/DRUPAL_FILES_LIVE
18-
echo "Triage : Found Drupal Filesystem."
14+
# Check if the database has tables named *node*. If so, this is likely a live DB.
15+
if [ -f /tmp/DRUPAL_FILES_LIVE ]; then
16+
TABLE_COUNT=$($DRUSH sql-query "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name LIKE '%node%';" --skip-column-names)
17+
if [ "$TABLE_COUNT" -gt 0 ]; then
18+
touch /tmp/DRUPAL_DB_LIVE
19+
echo "Triage : Found Drupal Database with $TABLE_COUNT node tables."
20+
fi
1921
fi

0 commit comments

Comments
 (0)