Project

General

Profile

Paste
Download (1.01 KB) Statistics
| Branch: | Revision:

root / bin / d7-all-gen-settings-local.sh @ 30fc561e

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 = '$base_url';#" < "${d7_settings_local_template}" > "${settings}"
21
    chmod 400 "${settings}"
22
    echo Done
23
done