fix: repair corrupted settings.php and simplify database injection logic

This commit is contained in:
fchinembiri 2026-05-21 19:27:17 +02:00
parent 63d283e549
commit c2aef7d400
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ spec:
lifecycle:
postStart:
exec:
command: ["sh", "-c", "if [ ! -f /opt/drupal/web/sites/default/settings.local.php ]; then cat <<EOF > /opt/drupal/web/sites/default/settings.local.php\n<?php\n\\$databases['default']['default'] = [\n 'database' => trim(getenv('FARMOS_DB_NAME') ?: ''),\n 'username' => trim(getenv('FARMOS_DB_USER') ?: ''),\n 'password' => trim(getenv('FARMOS_DB_PASS') ?: ''),\n 'prefix' => '',\n 'host' => trim(getenv('FARMOS_DB_HOST') ?: ''),\n 'port' => trim(getenv('FARMOS_DB_PORT') ?: ''),\n 'namespace' => 'Drupal\\\\Core\\\\Database\\\\Driver\\\\pgsql',\n 'driver' => 'pgsql',\n];\nEOF\nfi && sed -i '/settings.local.php/d' /opt/drupal/web/sites/default/settings.php && sed -i '/if (file_exists(\\$app_root/d' /opt/drupal/web/sites/default/settings.php && sed -i '/include \\$app_root/d' /opt/drupal/web/sites/default/settings.php && echo \"\nif (file_exists(\\$app_root . '/' . \\$site_path . '/settings.local.php')) {\n include \\$app_root . '/' . \\$site_path . '/settings.local.php';\n}\" >> /opt/drupal/web/sites/default/settings.php"]
command: ["sh", "-c", "cat <<EOF > /opt/drupal/web/sites/default/settings.local.php\n<?php\n\\$databases['default']['default'] = [\n 'database' => trim(getenv('FARMOS_DB_NAME') ?: ''),\n 'username' => trim(getenv('FARMOS_DB_USER') ?: ''),\n 'password' => trim(getenv('FARMOS_DB_PASS') ?: ''),\n 'prefix' => '',\n 'host' => trim(getenv('FARMOS_DB_HOST') ?: ''),\n 'port' => trim(getenv('FARMOS_DB_PORT') ?: ''),\n 'namespace' => 'Drupal\\\\Core\\\\Database\\\\Driver\\\\pgsql',\n 'driver' => 'pgsql',\n];\nEOF\nif ! grep -q \"settings.local.php\" /opt/drupal/web/sites/default/settings.php; then echo \"\nif (file_exists(\\$app_root . '/' . \\$site_path . '/settings.local.php')) {\n include \\$app_root . '/' . \\$site_path . '/settings.local.php';\n}\" >> /opt/drupal/web/sites/default/settings.php; fi"]
volumeMounts:
- name: sites
mountPath: /opt/drupal/web/sites