always recompute drupal settings from the original - to avoid ending up with mysql
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 22 Nov 2024 11:10:17 +0000 (12:10 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 22 Nov 2024 11:10:31 +0000 (12:10 +0100)
plewww.spec

index 39e421e..7d57633 100644 (file)
@@ -80,16 +80,20 @@ install -D -m 644 httpd/*.conf $RPM_BUILD_ROOT/etc/httpd/conf.d/
 drupal_settings_dir=/var/www/html/sites/default
 if [ ! -d $drupal_settings_dir ] ; then
     echo "Could not find directory $drupal_settings_dir"
-    echo "This suggests that you do not have a planetlab-custom drupal installed"
+    echo "This suggests you do not have a planetlab-custom drupal installed"
     exit 1
 fi
 pushd $drupal_settings_dir
 # tune $db_url
 if [ ! -f settings.php.drupal ] ; then
     cp settings.php settings.php.drupal
-    sed -e 's|^[ \t]*\$db_url.*|require_once("plc_config.php");$db_url="pgsql://" . PLC_DB_USER . ":" . PLC_DB_PASSWORD . "@" . PLC_DB_HOST . ":" . PLC_DB_PORT . "/drupal";|' \
-        settings.php.drupal > settings.php
 fi
+# always do this; it's idempotent
+# hopefully it will help in various upgrade scenarios where
+# drupal was re-installed, and settings.php was left in the original drupal state
+# which results in the infamous "cannot connect to mysql database"
+sed -e 's|^[ \t]*\$db_url.*|require_once("plc_config.php");$db_url="pgsql://" . PLC_DB_USER . ":" . PLC_DB_PASSWORD . "@" . PLC_DB_HOST . ":" . PLC_DB_PORT . "/drupal";|' \
+        settings.php.drupal > settings.php
 popd
 # append our own database creation hacks to the drupal database schema
 pushd /var/www/html/database