Project

General

Profile

Revision 3959842a

Added by Julien Enselme over 7 years ago

Add script to regenerate all settings.local.php from the template

Inspired by other-scripts/one-use/d7-all-gen-settings-local.sh

View differences:

bin/d7-all-gen-settings-local.sh
1
#!/bin/sh
2

  
3
. /home/assos/bin/scripts-config.sh
4
. /home/assos/bin/scripts-utils.sh
5

  
6
# Exit on error
7
set -e
8

  
9
# This script regenerate settings.local.php from the template for all sites.
10

  
11
for settings in $(find "${d7_dir_sites}" -mindepth 2 -maxdepth 2 -name settings.local.php) ; do
12
    # Get infos from settings.php
13
    db_name=$(grep "^ *'database' => '\(.*\)'" "${settings}" | sed "s/^ *'database' => '\(.*\)'.*/\1/")
14
    db_user=$(grep "^ *'username' => '\(.*\)'" "${settings}" | sed "s/^ *'username' => '\(.*\)'.*/\1/")
15
    db_password=$(grep "^ *'password' => '\(.*\)'" "${settings}" | sed "s/^ *'password' => '\(.*\)'.*/\1/")
16
    base_url=$(grep "^ *\$base_url = '\(.*\)'" "${settings}" | sed "s/^ *\$base_url = '\(.*\)'.*/\1/")
17

  
18
    echo "Changing ${settings}"
19
    chmod 600 "${settings}"
20
    sed "s/\%\%DBUSER\%\%/$db_user/ ; s/\%\%DBNAME\%\%/$db_name/ ; s/\%\%DBPASS\%\%/$db_password/ ; s#\%\%BASE_URL\%\%#$base_url#" < "${d7_settings_local_template}" > "${settings}"
21
    chmod 400 "${settings}"
22
    echo Done
23
done

Also available in: Unified diff