Projet

Général

Profil

Révision 5fbc698e

Ajouté par Julien Enselme il y a plus de 9 ans

Correctly generate map from sites.php.

Voir les différences:

bin/d7-create-site.sh
97 97
mv "${dir_tmp}/aliases.tmp" "${aliases_drushrc_php}"
98 98

  
99 99
### Update nginx_sites_map
100
echo $d7_site_name >> $nginx_site_names
101
# The sort must be reversed so that nginx aplly the rules correctly.
102
cat $nginx_site_names | sort -r > $nginx_site_names
103
update_nginx_map
100
d7-generate-nginx-map.sh
104 101

  
105 102
commit "Creation of site: ${d7_site_name}"
106 103

  
bin/d7-delete-site.sh
42 42
rm -r "${d7_dir_individual_manual_backup}/assos.centrale-marseille.fr.${d7_site_name}"
43 43

  
44 44
echo 'Remove site from nginx_map'
45
cat $nginx_site_names | grep -v $d7_site_name
46
update_nginx_map
47

  
48
echo 'Remove site from nginx_map'
49
cat $nginx_site_names | grep -v $d7_site_name
50
update_nginx_map
45
d7-generate-nginx-map.sh
51 46

  
52 47
echo "Don't forget to:"
53 48
echo "- Refresh node site on default"
bin/d7-generate-nginx-map.sh
1
#!/bin/sh
2

  
3
help=<<EOF
4
Generate nginx map from Drupal's sites.php
5

  
6
The left part of the map is $http_host$uri.
7
The right part is $subdir.
8
EOF
9

  
10
# Only for sites with url like assos.centrale-marseille.fr/subsite (other sites don't need to be in the map)
11
cut -d"'" -f2,4 "${sites_php}" |\
12
 grep '^assos\.centrale-marseille\.fr\.' |\
13
 # In reverse order.
14
 sort -r |\
15
 # Remove the ' at the end of the line.
16
 sed "s/'/ /" |\
17
 # Put slashes where they are needed (beware of tabs).
18
 sed 's/ assos.centrale-marseille.fr\./	/; s/assos.centrale-marseille.fr\./assos.centrale-marseille.fr\//; s/	/\/\.\*\$	\//; s/$/;/' >> "${d7_nginx_map_content}"
bin/scripts-config.sh
64 64
d7_settings_local_template_name="d7-settings-local-template.php"
65 65
d7_settings="${dir_template}/${d7_settings_name}"
66 66
d7_settings_local_template="${dir_template}/${d7_settings_local_template_name}"
67
nginx_map_template="$dir_template/template/nginx-map-template"
68 67

  
69 68
### Nginx
70
nginx_site_names=""
71
nginx_sites_map=""
69
$d7_nginx_map_content="${dir_multi_assos}/nginx_map"
bin/scripts-utils.sh
115 115
    fi
116 116
    return 1
117 117
}
118

  
119
update_nginx_map() {
120
    new_nginx_map_pattern=$(cat $nginx_site_names | tr "\n" "|" | head -c -1)
121
    sed s+"%%PATTERN%%"+"$new_nginx_map_pattern"+ < $nginx_map_template > $nginx_sites_map
122
}
template/nginx-map-template
1
map $uri $subsite {
2
    ~^/(?P<sub>%%PATTERN%%) $sub;
3
}

Formats disponibles : Unified diff