Project

General

Profile

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

root / other-scripts / d7-all-gen-settings-local.sh @ 140af436

1
#!/bin/sh
2

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

    
6
# This script generate settings.php and settings.local.php from settings.php
7

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

    
15
    settings_dir=`give_dir $settings`
16

    
17
    chmod 700 $settings
18

    
19
    rm $settings
20

    
21
    # We go into the settings.php directory.
22
    cd $settings_dir
23
    pwd
24

    
25
    cp $d7_settings settings.php
26
    chmod 400 settings.php
27

    
28
    sed "s/\%\%DBUSER\%\%/$db_user/ ; s/\%\%DBNAME\%\%/$db_name/ ; s/\%\%DBPASS\%\%/$db_password/ ; s#\%\%BASE_URL\%\%#$base_url#" < ~/tmp/d7-settings-local-template.php > settings.local.php
29

    
30
    chmod 400 settings.local.php
31
done