|
5 | 5 | rm -rf /tmp/DRUPAL_DB_LIVE |
6 | 6 | rm -rf /tmp/DRUPAL_FILES_LIVE |
7 | 7 |
|
| 8 | +# Check if we can connect to the database, and a node table exists. |
| 9 | +# DO not use drush as we are unsure of the filesystem state at this point. |
| 10 | +# Use the DRUPAL_DB_* environment variables set in the container. |
| 11 | +DB_CHECK=$( \ |
| 12 | + mysql \ |
| 13 | + --host="$DRUPAL_DB_HOSTNAME" \ |
| 14 | + --port="$DRUPAL_DB_PORT" \ |
| 15 | + --user="$DRUPAL_DB_USER" \ |
| 16 | + --password="$DRUPAL_DB_PASSWORD" \ |
| 17 | + --database="$DRUPAL_DB_NAME" \ |
| 18 | + --execute="SHOW TABLES LIKE 'node';" 2>/dev/null \ |
| 19 | +) |
| 20 | +if [ "$DB_CHECK" = "Tables_in_${DRUPAL_DB_NAME} (node)" ] || [ "$DB_CHECK" = "node" ]; then |
| 21 | + touch /tmp/DRUPAL_DB_LIVE |
| 22 | + echo "Triage : Found Drupal Database with node table." |
| 23 | +fi |
| 24 | + |
8 | 25 | # Determine if the site was previously built by checking for both .htaccess and settings.php in the public file dir. |
9 | 26 | if [ -f "$DRUPAL_ROOT/sites/default/files/.htaccess" ] && [ -f "$DRUPAL_ROOT/sites/default/files/settings.php" ]; then |
10 | 27 | touch /tmp/DRUPAL_FILES_LIVE |
11 | 28 | echo "Triage : Found Drupal Filesystem and settings.php." |
12 | 29 | fi |
13 | 30 |
|
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 |
21 | | -fi |
|
0 commit comments