Projet

Général

Profil

Révision 6c6343d9

Ajouté par Julien Enselme il y a environ 9 ans

Improve the detection of default with the path of a site.

Use a utilitary function to extract the exact site name from a site path.

Close #572

Voir les différences:

bin/d7-all-reset-variables.sh
1 1
#!/bin/sh
2 2

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

  
5 6
for dir in $(find "${d7_dir_sites}" -maxdepth 1 -mindepth 1 -type d ! -name all | sort); do
6 7
    echo "${dir}"
7
    site_name=$(echo "${dir}" | tr '.' '\n' | tail -n 1)
8
    site_name=$(get_site_name_from_dir_name "${dir}")
8 9
    d7-reset-variables.sh "${site_name}"
9 10
done
bin/d7-reset-piwik-variables.sh
85 85
esac
86 86

  
87 87
# Default is an exception and cannot be treated in the case
88
if echo "$1" | grep -q default ; then
88
if [ "$1" = 'default' ] ; then
89 89
    piwik_id=101
90 90
fi
91 91

  
bin/d7-reset-variables.sh
9 9

  
10 10
if [ -n "$1" ] ; then
11 11
    param="$1" . /home/assos/bin/scripts-config-site.sh
12
    # default is an exception to the rule
13
    # find returns the name of the as the absolute path, hence the use of grep
14
    # and not =
15
    if echo "$1" | grep -q default ; then
12
    if [ "$1" = 'default' ] ; then
16 13
	cd "${d7_dir_sites}/default"
17 14
    else
18 15
	cd "${d7_site_dir}"
bin/scripts-utils.sh
115 115
    fi
116 116
    return 1
117 117
}
118

  
119
get_site_name_from_dir_name() {
120
    # ${1##*/} get the part after the last / ie default in /home/assos/drupal7/sites/default
121
    # $(tr '.' '\n' | tail -n 1) get the part after the last .
122
    # ie tvp in assos.centrale-marseille.fr.tvp
123
    echo $(echo ${1##*/} | tr '.' '\n' | tail -n 1)
124
}

Formats disponibles : Unified diff