Scripts et taches planifiees » Historique » Version 61
Julien Enselme, 05/08/2013 18:45
flush-individual-databases-backups.sh : code after validation
1 | 1 | Julien Enselme | Afin de gagner du temps et d'éviter les erreurs humaines, des scripts ont été écrits tout au long du projet. Certains sont même exécutés automatiquement toutes les semaines. |
---|---|---|---|
2 | |||
3 | 13 | Florent Torregrosa | {{>toc}} |
4 | 1 | Julien Enselme | |
5 | h1. Les tâches planifiées |
||
6 | |||
7 | 26 | Florent Torregrosa | h2. Crontab |
8 | |||
9 | 3 | Julien Enselme | Pour exécuter ces tâches régulièrement, on utilise le "crontab":http://fr.wikipedia.org/wiki/Crontab. Il s'agit d'un programme installé sur notre serveur. |
10 | 1 | Julien Enselme | |
11 | 3 | Julien Enselme | Pour voir et modifier la liste des actions : |
12 | # se connecter au serveur : <code>ssh assos@sas1.centrale-marseille</code> |
||
13 | # taper la commande pour voir le crontab <code>crontab -l</code> |
||
14 | 47 | Julien Enselme | # taper la commande pour modifier le crontab <code>crontab -e</code>. |
15 | 1 | Julien Enselme | |
16 | 47 | Julien Enselme | {{important(Ne pas effectuer cette opération avant de s'être renseigné sur "vi":http://fr.wikipedia.org/wiki/Vi (l'éditeur de texte utilisé qui n'est pas vraiment intuitif :p) et sur "la syntaxe du crontab":http://fr.wikipedia.org/wiki/Crontab#Modification ! |
17 | Les scripts doivent si possible s’exécuter avant le club Drupal pour que les problèmes éventuels y soient réglés)}} |
||
18 | |||
19 | 52 | Julien Enselme | {{tip(Pour utiliser un autre éditeur que vi taper : export EDITOR=editor_name exemple : vim, nano |
20 | d7-all-update-contrib.sh fait des sauvegardes automatiques individuelles pour les sites drupal)}} |
||
21 | 26 | Florent Torregrosa | |
22 | <pre> |
||
23 | <code class="php"> |
||
24 | 42 | Florent Torregrosa | ######## How to use |
25 | # mm hh jj MMM JJJ task |
||
26 | # minutes hour day_month month day_week |
||
27 | # for more informations : https://fr.wikipedia.org/wiki/Crontab#Notation |
||
28 | ######## End how to |
||
29 | |||
30 | 43 | Florent Torregrosa | ### Traqu-heure |
31 | 43 6 * * * /users/guest/assos/bin/traqu_heure/script-restitution.sh > /dev/null 2>&1 |
||
32 | 0 * * * * /users/guest/assos/bin/traqu_heure/script-traque.sh > /dev/null 2>&1 |
||
33 | 1 | Julien Enselme | |
34 | |||
35 | 43 | Florent Torregrosa | ### Cleaning |
36 | 00 22 * * * /users/guest/assos/bin/all-reset-permissions.sh > /dev/null 2>&1 |
||
37 | 00 23 * * * /users/guest/assos/bin/delete-temporary-files.sh > /dev/null 2>&1 |
||
38 | 1 | Julien Enselme | |
39 | |||
40 | 43 | Florent Torregrosa | ### Databases |
41 | # Create backup |
||
42 | 00 21 * * 1 /users/guest/assos/bin/d7-all-dump-full.sh > /dev/null 2>&1 |
||
43 | 00 1 * * 2 /users/guest/assos/bin/d6-all-dump-full.sh > /dev/null 2>&1 |
||
44 | 42 | Florent Torregrosa | |
45 | 43 | Florent Torregrosa | # flush backup |
46 | 00 21 * * 2 /users/guest/assos/bin/flush-full-databases-backups.sh d7 > /dev/null 2>&1 |
||
47 | 00 22 * * 2 /users/guest/assos/bin/flush-full-databases-backups.sh d6 > /dev/null 2>&1 |
||
48 | 00 23 * * 2 /users/guest/assos/bin/flush-individual-databases-backups.sh auto d7 > /dev/null 2>&1 |
||
49 | 00 1 * * 3 /users/guest/assos/bin/flush-individual-databases-backups.sh manual d7 > /dev/null 2>&1 |
||
50 | 42 | Florent Torregrosa | |
51 | |||
52 | 43 | Florent Torregrosa | ### Updates for drupal 7 |
53 | 00 22 * * 3 /users/guest/assos/bin/d7-all-update-contrib.sh | mail -s "d7-all-update-contrib.sh" assos |
||
54 | 56 | Julien Enselme | 00 1 * * 3 /users/guest/assos/bin/d7-all-update-localisation.sh | mail -s "d7-all-update-localisation.sh" assos |
55 | 43 | Florent Torregrosa | 00 3 * * 3 /users/guest/assos/bin/d7-all-reset-variables.sh > /dev/null 2>&1 |
56 | 42 | Florent Torregrosa | |
57 | 44 | Florent Torregrosa | 00 5 * * 3 /users/guest/assos/bin/d7-all-releases-info.sh | mail -s "d7-all-releases-info.sh" assos |
58 | 43 | Florent Torregrosa | 00 23 * * 4 /users/guest/assos/bin/d7-all-security-review.sh |
59 | 42 | Florent Torregrosa | |
60 | |||
61 | 43 | Florent Torregrosa | # Updates for drupal 6 |
62 | 00 22 * * 6 /users/guest/assos/bin/d6-all-update-contrib.sh > /dev/null 2>&1 |
||
63 | 00 23 * * 6 /users/guest/assos/bin/d6-all-reset-variables.sh > /dev/null 2>&1 |
||
64 | 42 | Florent Torregrosa | |
65 | 43 | Florent Torregrosa | # Launch drush cron on fellowings |
66 | 45 17 * * * /users/guest/assos/bin/drushcronone assos.centrale-marseille.fr.ginfo > /dev/null 2>&1 |
||
67 | */15 * * * * /users/guest/assos/bin/drushcronone assos.centrale-marseille.fr.clubfinance > /dev/null 2>&1 |
||
68 | 45 3 * * * /users/guest/assos/bin/drushcronone default > /dev/null 2>&1 |
||
69 | 35 00 * * * /users/guest/assos/bin/drushcronone assos.centrale-marseille.fr.cac13 > /dev/null 2>&1 |
||
70 | */45 * * * * /users/guest/assos/bin/drushcronone assos.centrale-marseille.fr.expat > /dev/null 2>&1 |
||
71 | 1 | Julien Enselme | */10 * * * * /users/guest/assos/bin/drushcronone forum.centrale-marseille.fr > /dev/null 2>&1 |
72 | 44 | Florent Torregrosa | |
73 | 00 22 * * 7 /users/guest/assos/bin/disk-usage.sh | mail -s "disk-usage.sh" assos |
||
74 | 1 | Julien Enselme | |
75 | </code> |
||
76 | 25 | Florent Torregrosa | </pre> |
77 | 1 | Julien Enselme | |
78 | 25 | Florent Torregrosa | Voici la liste des tâches effectuées régulièrement. |
79 | 3 | Julien Enselme | |
80 | 25 | Florent Torregrosa | h2. La réinitialisation des variables |
81 | |||
82 | 1 | Julien Enselme | Cette tâche consiste à réinitialiser certaines variables qui donnent des droits considérés comme trop permissifs donc dangereux aux administrateurs des sites ou nécessaire pour d'autres scripts tels que piwik ou security_review. |
83 | |||
84 | 25 | Florent Torregrosa | En voici quelques exemples : |
85 | 1 | Julien Enselme | |
86 | <pre> |
||
87 | <code class="bash"> |
||
88 | 25 | Florent Torregrosa | drush -y vset error_level 0 |
89 | </code> |
||
90 | 1 | Julien Enselme | </pre> |
91 | 21 | Florent Torregrosa | |
92 | 25 | Florent Torregrosa | Cette commande permet de ne pas afficher les messages d'erreurs. En effet, ils contiennent parfois des informations sensibles sur l'installation et ne doivent donc pas être divulgués à n'importe qui. |
93 | |||
94 | 3 | Julien Enselme | <pre> |
95 | 1 | Julien Enselme | <code class="php"> |
96 | drush -y vset --always-set reverse_proxy TRUE |
||
97 | 25 | Florent Torregrosa | drush -y vset --always-set --format=json reverse_proxy_addresses '["147.94.19.16","147.94.19.17"]' |
98 | 1 | Julien Enselme | </code> |
99 | 3 | Julien Enselme | </pre> |
100 | 1 | Julien Enselme | |
101 | 3 | Julien Enselme | Ces commandes permettent de déclarer à Drupal les serveurs proxy du CRI afin d'éviter qu'il ne répertorie tous les visiteurs comme ayant l'adresse des serveurs sus-cités. **Pas fini : voir http://assos.centrale-marseille.fr/content/t%C3%A2che/d%C3%A9clarer-les-proxy-du-cri-%C3%A0-drupal** |
102 | 1 | Julien Enselme | |
103 | 6 | Julien Enselme | h2. La sauvegarde des bases de données |
104 | 1 | Julien Enselme | |
105 | 3 | Julien Enselme | Sur les installations d6 et d7 : une fois par semaine |
106 | 1 | Julien Enselme | |
107 | 3 | Julien Enselme | On utilise les [[Scripts_et_taches_planifiees#Tout-sauvegarder|scripts de sauvegarde créés par le club Drupal]]. |
108 | 1 | Julien Enselme | |
109 | 3 | Julien Enselme | h2. La purge des sauvegardes de bdd |
110 | 1 | Julien Enselme | |
111 | Sur les installations d6 et d7 : toutes les semaines |
||
112 | |||
113 | Cette tâche utilise le script de [[Scripts_et_taches_planifiees#purge_des_sauvegardes.sh|purge des sauvegardes]] afin de libérer de l'espace disque en supprimant les sauvegardes de bdd les plus vieilles. |
||
114 | |||
115 | h1. Liste des scripts à disposition |
||
116 | 21 | Florent Torregrosa | |
117 | Les scripts utilisés sont hébergés dans le répertoire bin du compte assos. |
||
118 | |||
119 | 53 | Julien Enselme | h2. Configuration et utilitaires |
120 | 1 | Julien Enselme | |
121 | 53 | Julien Enselme | h3. scripts-config-site.sh |
122 | |||
123 | 21 | Florent Torregrosa | <pre> |
124 | <code class="php"> |
||
125 | #!/bin/sh |
||
126 | 1 | Julien Enselme | |
127 | 53 | Julien Enselme | # Sets useful variables of a site. |
128 | # ARGS: site_name |
||
129 | # Requires scripts-config.sh |
||
130 | |||
131 | # Check if scripts-config.sh is imported. |
||
132 | if [ -z $scripts_config ] ; then |
||
133 | echo "Import of scripts-config.sh required." |
||
134 | exit 1 |
||
135 | fi |
||
136 | |||
137 | if [ -z $1 ] ; then |
||
138 | echo "This script needs a site name as argument." |
||
139 | exit 1 |
||
140 | fi |
||
141 | |||
142 | scripts_config_site='imported' |
||
143 | |||
144 | d7_site_name=$1 |
||
145 | d7_site_dir="$d7_dir_sites/assos.centrale-marseille.fr.$d7_site_name" |
||
146 | d7_site_settings="$d7_site_dir/settings.php" |
||
147 | </code> |
||
148 | </pre> |
||
149 | |||
150 | h3. scripts-config.sh |
||
151 | |||
152 | <pre> |
||
153 | <code class="php"> |
||
154 | #!/bin/sh |
||
155 | |||
156 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/users/guest/assos/bin |
||
157 | PATH=$PATH:/usr/guest/assos/bin |
||
158 | |||
159 | scripts_config='imported' |
||
160 | |||
161 | email_multi_assos="assos@centrale-marseille.fr" |
||
162 | |||
163 | dir_multi_assos='/users/guest/assos' |
||
164 | dir_scripts="$dir_multi_assos/bin" |
||
165 | dir_template="$dir_multi_assos/template" |
||
166 | |||
167 | ###### Database |
||
168 | db_server="myassos.serv.int" |
||
169 | db_user="assos" |
||
170 | dir_log="$dir_multi_assos/log" |
||
171 | |||
172 | ###### Backup |
||
173 | db_full_backup_number=3 |
||
174 | db_individual_manual_backup_number=3 |
||
175 | db_individual_auto_backup_number=3 |
||
176 | |||
177 | dir_backup="$dir_multi_assos/backup" |
||
178 | dir_full_backup="$dir_backup/full" |
||
179 | dir_individual_backup="$dir_backup/individual" |
||
180 | dir_individual_manual_backup="$dir_individual_backup/manual" |
||
181 | dir_individual_auto_backup="$dir_individual_backup/auto" |
||
182 | |||
183 | |||
184 | ###### D7 variables |
||
185 | d7_dir="$dir_multi_assos/htmltest" |
||
186 | d7_dir_sites="$d7_dir/sites" |
||
187 | |||
188 | ### Log |
||
189 | d7_dir_log="$dir_log/d7" |
||
190 | |||
191 | ### Backup |
||
192 | d7_dir_full_backup="$dir_full_backup/d7" |
||
193 | d7_dir_individual_manual_backup="$dir_individual_manual_backup/d7" |
||
194 | d7_dir_individual_auto_backup="$dir_individual_auto_backup/d7" |
||
195 | |||
196 | ### Template |
||
197 | d7_settings_template_name="settings-D7-bddinde-template.php" |
||
198 | d7_settings_template="$dir_template/$d7_settings_template_name" |
||
199 | |||
200 | |||
201 | ###### D6 variables |
||
202 | d6_dir="$dir_multi_assos/html" |
||
203 | d6_dir_sites="$d6_dir/sites" |
||
204 | |||
205 | ### Backup |
||
206 | d6_dir_full_backup="$dir_full_backup/d6" |
||
207 | d6_dir_individual_manual_backup="$dir_individual_manual_backup/d6" |
||
208 | d6_dir_individual_auto_backup="$dir_individual_auto_backup/d6" |
||
209 | </code> |
||
210 | </pre> |
||
211 | |||
212 | h3. scripts-utils.sh |
||
213 | |||
214 | <pre> |
||
215 | <code class="php"> |
||
216 | #!/bin/sh |
||
217 | |||
218 | # This script contains useful functions for other scripts. |
||
219 | |||
220 | # Check if scripts-config.sh is imported. |
||
221 | if [ -z $scripts_config ] ; then |
||
222 | echo "Import of scripts-config.sh required." |
||
223 | 58 | Julien Enselme | . scripts-config.sh |
224 | 53 | Julien Enselme | fi |
225 | |||
226 | scripts_utils='imported' |
||
227 | |||
228 | ask_password() { |
||
229 | # read -s doesn't work with sh. |
||
230 | # usage: pass=`ask_password "password please:"` |
||
231 | echo $1 >&2 |
||
232 | echo -n ">" >&2 |
||
233 | stty_avant=`stty -g` |
||
234 | stty -echo |
||
235 | read password |
||
236 | stty $stty_avant |
||
237 | echo "$password" |
||
238 | unset password |
||
239 | } |
||
240 | |||
241 | ask_password_db() { |
||
242 | # ARGS: server_name, user_name |
||
243 | local db_password="pour_boucler" |
||
244 | # empty db request to validate password |
||
245 | while ! mysql -h $1 -u $2 -p$db_password -e "" 2>/dev/null ; do |
||
246 | db_password=`ask_password "database password:"` |
||
247 | done |
||
248 | echo $db_password |
||
249 | } |
||
250 | |||
251 | generate_password(){ |
||
252 | # ARGS: [password_length] |
||
253 | # The password contains special characters. '/' must be excluded to avoid sed malfunction. |
||
254 | |||
255 | local site_password='/' |
||
256 | |||
257 | if [ -z $1 ] ; then |
||
258 | local password_length=20 |
||
259 | else |
||
260 | local password_length=$1 |
||
261 | fi |
||
262 | |||
263 | while echo "$site_password" | grep -Fq '/' ; do |
||
264 | site_password=`dd if=/dev/urandom count=1 | uuencode -m - | head -n 2 | tail -n 1 | cut -c-$password_length` |
||
265 | done |
||
266 | |||
267 | echo $site_password |
||
268 | } |
||
269 | |||
270 | count_d7_sites(){ |
||
271 | find $d7_dir_sites -type d ! -name all -maxdepth 1 | wc -l |
||
272 | } |
||
273 | |||
274 | check_arguments() { |
||
275 | # ARGS: number of arguments passed to script, number of arguments required |
||
276 | if [ $1 -lt $2 ] ; then |
||
277 | echo "Number of arguments insuffisant." |
||
278 | exit 1 |
||
279 | fi |
||
280 | } |
||
281 | </code> |
||
282 | </pre> |
||
283 | |||
284 | h2. Scripts généraux |
||
285 | |||
286 | h3. all-reset-permissions.sh |
||
287 | |||
288 | <pre> |
||
289 | <code class="php"> |
||
290 | #!/bin/sh |
||
291 | |||
292 | 21 | Florent Torregrosa | . scripts-config.sh |
293 | |||
294 | # This script puts the correct permissions to sites folders, settings.php and scripts. |
||
295 | |||
296 | ######### drupal 6 |
||
297 | for dir in `find $d6_dir_sites -type d -maxdepth 1 -mindepth 1 ! -name all ! -name images ! -name languages` ; do |
||
298 | chmod 755 $dir |
||
299 | chmod 400 $dir/settings.php |
||
300 | 35 | Florent Torregrosa | done |
301 | |||
302 | ######### drupal 7 |
||
303 | for dir in `find $d7_dir_sites -type d -maxdepth 1 -mindepth 1 ! -name all` ; do |
||
304 | chmod 755 $dir |
||
305 | chmod 400 $dir/settings.php |
||
306 | 21 | Florent Torregrosa | done |
307 | |||
308 | 1 | Julien Enselme | ####### bin |
309 | 21 | Florent Torregrosa | chmod -R 700 $dir_scripts |
310 | |||
311 | ####### backup |
||
312 | chmod -R 700 $dir_backup |
||
313 | |||
314 | ####### log |
||
315 | chmod -R 700 $dir_log |
||
316 | </code> |
||
317 | 1 | Julien Enselme | </pre> |
318 | 21 | Florent Torregrosa | |
319 | 53 | Julien Enselme | h3. contrib-usage.sh |
320 | 29 | Florent Torregrosa | |
321 | 21 | Florent Torregrosa | <pre> |
322 | <code class="php"> |
||
323 | #!/bin/sh |
||
324 | |||
325 | . scripts-config.sh |
||
326 | . scripts-utils.sh |
||
327 | |||
328 | # ARGS: Drupal_version, project_status, project_name |
||
329 | # List sites that have the project_name with the corresponding project_status. |
||
330 | 41 | Florent Torregrosa | # project status: enabled or disabled |
331 | 21 | Florent Torregrosa | |
332 | check_arguments $# 3 |
||
333 | |||
334 | if [ $1 = d6 ] ; then |
||
335 | cd $d6_dir_sites |
||
336 | else |
||
337 | cd $d7_dir_sites |
||
338 | fi |
||
339 | 29 | Florent Torregrosa | |
340 | 21 | Florent Torregrosa | for dir in `find . -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort ` ; do |
341 | # List non-core projects that correspond to the status. |
||
342 | # Keep project_name if listed. |
||
343 | # Count line result. 0 if not listed or 1 if listed. |
||
344 | 1 | Julien Enselme | # Print site_dir if listed. |
345 | 21 | Florent Torregrosa | |
346 | cd $dir; |
||
347 | if [ 1 -eq `drush pml --no-core --status=$2 | grep $3 | wc -l` ] ; then |
||
348 | echo $dir; |
||
349 | fi |
||
350 | cd - |
||
351 | done |
||
352 | 1 | Julien Enselme | </code> |
353 | 21 | Florent Torregrosa | </pre> |
354 | |||
355 | 53 | Julien Enselme | h3. delete-temporary-files.sh |
356 | 21 | Florent Torregrosa | |
357 | 41 | Florent Torregrosa | <pre> |
358 | 21 | Florent Torregrosa | <code class="php"> |
359 | 1 | Julien Enselme | #!/bin/sh |
360 | |||
361 | . scripts-config.sh |
||
362 | 53 | Julien Enselme | |
363 | find $dir_multi_assos -name '*~' -delete |
||
364 | </code> |
||
365 | </pre> |
||
366 | |||
367 | h3. disk-usage.sh |
||
368 | |||
369 | <pre> |
||
370 | <code class="php"> |
||
371 | #!/bin/sh |
||
372 | |||
373 | . scripts-config.sh |
||
374 | |||
375 | echo -e "Quotas: 9.1 GB\n" |
||
376 | |||
377 | echo "Assos:" |
||
378 | du -hcs $dir_multi_assos | grep total |
||
379 | echo -e "\n" |
||
380 | |||
381 | echo "D6:" |
||
382 | cd $d6_dir_sites |
||
383 | du -h -d 1 |
||
384 | echo -e "\n" |
||
385 | |||
386 | echo "D7:" |
||
387 | cd $d7_dir_sites |
||
388 | du -h -d 1 |
||
389 | echo -e "\n" |
||
390 | |||
391 | echo "Logs:" |
||
392 | du -hcs $dir_log | grep total |
||
393 | echo -e "\n" |
||
394 | |||
395 | echo "Backups:" |
||
396 | cd $dir_backup |
||
397 | du -h -d 2 |
||
398 | </code> |
||
399 | </pre> |
||
400 | |||
401 | h3. drushcronone |
||
402 | |||
403 | <pre> |
||
404 | <code class="php"> |
||
405 | #!/bin/sh |
||
406 | |||
407 | . scripts-config.sh |
||
408 | |||
409 | if [ $# -lt 1 ]; then |
||
410 | echo "usage: $0 <site's folder name>" |
||
411 | exit 1 |
||
412 | fi |
||
413 | |||
414 | cd "$d6_sites_dir/$*" |
||
415 | pwd; |
||
416 | drush cron; |
||
417 | </code> |
||
418 | </pre> |
||
419 | |||
420 | h3. flush-files.sh |
||
421 | |||
422 | <pre> |
||
423 | <code class="php"> |
||
424 | #!/bin/sh |
||
425 | |||
426 | 60 | Julien Enselme | # ARGS: number of files to keep, [email address] |
427 | 53 | Julien Enselme | # usage: flush files from a folder except a number equal to argument. |
428 | |||
429 | # Check if scripts-config.sh is imported. |
||
430 | if [ -z $scripts_utils ] ; then |
||
431 | echo "Import of scripts-utils.sh required." |
||
432 | 57 | Julien Enselme | . scripts-utils.sh |
433 | 53 | Julien Enselme | fi |
434 | |||
435 | 60 | Julien Enselme | check_arguments $# 1 |
436 | 53 | Julien Enselme | |
437 | backups_number=`ls | wc -l` |
||
438 | 60 | Julien Enselme | let "number_of_backups_to_delete = backups_number - $1" > /dev/null |
439 | 53 | Julien Enselme | |
440 | 1 | Julien Enselme | if [ $number_of_backups_to_delete -gt 0 ] ; then |
441 | ls | head -$number_of_backups_to_delete | xargs rm |
||
442 | 53 | Julien Enselme | else |
443 | 60 | Julien Enselme | if [ ! -z $2 ] ; then |
444 | dir=`pwd` |
||
445 | echo "There are not enough files in $dir to Flush it. Check if backup script works fine." | mail -s "[db] $dir has a backup problem" $2 |
||
446 | fi |
||
447 | 53 | Julien Enselme | fi |
448 | </code> |
||
449 | </pre> |
||
450 | |||
451 | h3. flush-full-databases-backups.sh |
||
452 | |||
453 | <pre> |
||
454 | <code class="php"> |
||
455 | #!/bin/sh |
||
456 | |||
457 | . scripts-config.sh |
||
458 | |||
459 | # ARGS: Drupal version |
||
460 | |||
461 | cd $dir_full_backup/$1 |
||
462 | |||
463 | for dir in `ls` ; do |
||
464 | cd $dir |
||
465 | flush-files.sh $db_full_backup_number $email_multi_assos |
||
466 | cd - |
||
467 | done |
||
468 | </code> |
||
469 | </pre> |
||
470 | |||
471 | h3. flush-individual-databases-backups.sh |
||
472 | |||
473 | <pre> |
||
474 | <code class="php"> |
||
475 | #!/bin/sh |
||
476 | |||
477 | . scripts-config.sh |
||
478 | |||
479 | # ARGS: manual or auto, Drupal version |
||
480 | |||
481 | cd $dir_individual_backup/$1/$2 |
||
482 | |||
483 | for dir in `ls` ; do |
||
484 | cd $dir |
||
485 | if [ $1 = 'auto' ] ; then |
||
486 | flush-files.sh $db_individual_auto_backup_number $email_multi_assos |
||
487 | else |
||
488 | 61 | Julien Enselme | flush-files.sh $db_individual_manual_backup_number |
489 | 53 | Julien Enselme | fi |
490 | cd - |
||
491 | done |
||
492 | </code> |
||
493 | </pre> |
||
494 | |||
495 | h2. Scripts Drupal 6 |
||
496 | |||
497 | h3. d6-all-drush.sh |
||
498 | |||
499 | <pre> |
||
500 | <code class="php"> |
||
501 | #!/bin/sh |
||
502 | |||
503 | . scripts-config.sh |
||
504 | 21 | Florent Torregrosa | . scripts-utils.sh |
505 | |||
506 | # ARGS: drush_command |
||
507 | |||
508 | check_arguments $# 1 |
||
509 | |||
510 | for dir in `find $d6_dir_sites -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort` ; do |
||
511 | cd $dir |
||
512 | echo $dir |
||
513 | drush $* |
||
514 | 1 | Julien Enselme | done |
515 | 21 | Florent Torregrosa | </code> |
516 | 45 | Florent Torregrosa | </pre> |
517 | 21 | Florent Torregrosa | |
518 | 53 | Julien Enselme | h3. d6-all-dump-full.sh |
519 | 45 | Florent Torregrosa | |
520 | 37 | Florent Torregrosa | <pre> |
521 | <code class="php"> |
||
522 | #!/bin/sh |
||
523 | |||
524 | . scripts-config.sh |
||
525 | |||
526 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
527 | |||
528 | # Dump D6 database with webassos user. |
||
529 | mysqldump --single-transaction webassos -h myweb.serv.int -u webassos --password=password > $d6_dir_full_backup/webassos/$current_date.webassos.sql |
||
530 | 41 | Florent Torregrosa | |
531 | 1 | Julien Enselme | # Dump D6 form database with forum user. |
532 | 37 | Florent Torregrosa | mysqldump forum -h myweb.serv.int -u forum --password=password > $d6_dir_full_backup/forum/$current_date.forum.sql |
533 | </code> |
||
534 | 39 | Florent Torregrosa | </pre> |
535 | 1 | Julien Enselme | |
536 | 53 | Julien Enselme | h3. d6-all-reset-variables.sh |
537 | 21 | Florent Torregrosa | |
538 | <pre> |
||
539 | <code class="php"> |
||
540 | #!/bin/sh |
||
541 | |||
542 | . scripts-config.sh |
||
543 | |||
544 | cd $d6_dir_sites |
||
545 | 1 | Julien Enselme | d6-all-drush.sh vset --always-set reverse_proxy TRUE |
546 | 21 | Florent Torregrosa | d6-all-drush.sh vset --always-set --format=json reverse_proxy_addresses '["147.94.19.16","147.94.19.17"]' |
547 | drush @sites -y ev "variable_set('update_notify_emails', array('@email_multi_assos'));" |
||
548 | </code> |
||
549 | </pre> |
||
550 | |||
551 | 53 | Julien Enselme | h3. d6-all-update-contrib.sh |
552 | 21 | Florent Torregrosa | |
553 | <pre> |
||
554 | <code class="php"> |
||
555 | #!/bin/sh |
||
556 | |||
557 | . scripts-config.sh |
||
558 | |||
559 | d6-all-drush.sh -y en update |
||
560 | 1 | Julien Enselme | # Launch cron to check for updates. |
561 | 21 | Florent Torregrosa | d6-all-drush.sh -q cron |
562 | |||
563 | d6-all-drush.sh cc all |
||
564 | d6-all-dump-full.sh |
||
565 | |||
566 | d6-all-drush.sh -y upc --no-core |
||
567 | 1 | Julien Enselme | d6-all-drush.sh -y updb |
568 | |||
569 | d6-all-drush.sh -y dis update |
||
570 | |||
571 | d6-all-drush.sh cron |
||
572 | </code> |
||
573 | </pre> |
||
574 | 41 | Florent Torregrosa | |
575 | 53 | Julien Enselme | h3. d6-dump-individual.sh |
576 | 41 | Florent Torregrosa | |
577 | <pre> |
||
578 | <code class="php"> |
||
579 | #!/bin/sh |
||
580 | |||
581 | . scripts-config.sh |
||
582 | 21 | Florent Torregrosa | |
583 | # ARGS: auto or manual, site_prefix |
||
584 | # WARNING : backup are regularly flushed, put your backup in a safe place. |
||
585 | |||
586 | cd $dir_individual_backup |
||
587 | 1 | Julien Enselme | |
588 | #!/bin/sh |
||
589 | |||
590 | . scripts-config.sh |
||
591 | 21 | Florent Torregrosa | |
592 | 1 | Julien Enselme | # ARGS: auto or manual, site_prefix |
593 | 21 | Florent Torregrosa | # WARNING : backup are regularly flushed, put your backup in a safe place. |
594 | |||
595 | cd $dir_individual_backup |
||
596 | |||
597 | 41 | Florent Torregrosa | #récupération des tables du site dans le fichier liste_tables.temp |
598 | tables='_%' |
||
599 | liste="$1$tables" |
||
600 | |||
601 | 21 | Florent Torregrosa | mysql -h myweb.serv.int -u webassos --password=HBVH2ljgyZCA0AP251DY -BNe "show tables like '"$liste"'" webassos | tr '\r\n' ' ' > liste_tables.temp |
602 | |||
603 | #transformation de cette liste en une variable |
||
604 | var=$(cat liste_tables.temp) |
||
605 | |||
606 | 1 | Julien Enselme | #sauvegarde de toutes ces tables |
607 | 21 | Florent Torregrosa | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
608 | suffixe="_dump$current_date.sql" |
||
609 | fichier="$1$suffixe" |
||
610 | |||
611 | 1 | Julien Enselme | if [ $1 = 'auto' ] ; then |
612 | 21 | Florent Torregrosa | mysqldump webassos -h myweb.serv.int -u webassos --password=HBVH2ljgyZCA0AP251DY $var > $d6_dir_individual_auto_backup/$fichier |
613 | else |
||
614 | 1 | Julien Enselme | mysqldump webassos -h myweb.serv.int -u webassos --password=HBVH2ljgyZCA0AP251DY $var > $d6_dir_individual_manual_backup/$fichier |
615 | 21 | Florent Torregrosa | fi |
616 | 1 | Julien Enselme | |
617 | #suppression du fichier temporaire utilisé |
||
618 | 21 | Florent Torregrosa | rm liste_tables.temp |
619 | </code> |
||
620 | </pre> |
||
621 | |||
622 | 53 | Julien Enselme | h2. Scripts Drupal 7 |
623 | 30 | Florent Torregrosa | |
624 | 53 | Julien Enselme | h3. d7-all-drush-logged.sh |
625 | |||
626 | 1 | Julien Enselme | <pre> |
627 | 30 | Florent Torregrosa | <code class="php"> |
628 | #!/bin/sh |
||
629 | |||
630 | 21 | Florent Torregrosa | . scripts-config.sh |
631 | 30 | Florent Torregrosa | . scripts-utils.sh |
632 | |||
633 | 21 | Florent Torregrosa | # ARGS: drush_command |
634 | |||
635 | check_arguments $# 1 |
||
636 | 1 | Julien Enselme | |
637 | 21 | Florent Torregrosa | cd $d7_dir_sites |
638 | 1 | Julien Enselme | |
639 | 21 | Florent Torregrosa | for dir in `find . -maxdepth 1 -mindepth 1 -type d ! -name all | sort` ; do |
640 | cd $dir |
||
641 | current_date=`date "+%Y-%m-%d_%Hh:%Mm"` |
||
642 | echo "======$current_date======" >> $d7_dir_log/$dir.log |
||
643 | 1 | Julien Enselme | echo "Arguments are: $* " >> $d7_dir_log/$dir.log |
644 | 21 | Florent Torregrosa | drush $* >> $d7_dir_log/$dir.log |
645 | #To have the same caracters limit we needed 'end' that have 4 caracters, we used the Croate language for this ! LOL |
||
646 | echo -e "=============KRAJ=============\n" >> $d7_dir_log/$dir.log |
||
647 | cd - |
||
648 | done |
||
649 | </code> |
||
650 | </pre> |
||
651 | 41 | Florent Torregrosa | |
652 | 53 | Julien Enselme | h3. d7-all-drush.sh |
653 | 21 | Florent Torregrosa | |
654 | <pre> |
||
655 | <code class="php"> |
||
656 | #!/bin/sh |
||
657 | |||
658 | . scripts-config.sh |
||
659 | 1 | Julien Enselme | . scripts-utils.sh |
660 | 21 | Florent Torregrosa | |
661 | # ARGS: drush_command |
||
662 | |||
663 | 1 | Julien Enselme | check_arguments $# 1 |
664 | 21 | Florent Torregrosa | |
665 | for dir in `find $d7_dir_sites -maxdepth 1 -mindepth 1 -type d ! -name all | sort` ; do |
||
666 | cd $dir |
||
667 | echo $dir |
||
668 | drush $* |
||
669 | done |
||
670 | </code> |
||
671 | </pre> |
||
672 | |||
673 | 53 | Julien Enselme | h3. d7-all-dump-full.sh |
674 | 21 | Florent Torregrosa | |
675 | 45 | Florent Torregrosa | <pre> |
676 | 21 | Florent Torregrosa | <code class="php"> |
677 | 1 | Julien Enselme | #!/bin/sh |
678 | 21 | Florent Torregrosa | |
679 | . scripts-config.sh |
||
680 | |||
681 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
682 | |||
683 | # Dump D7 databases at once. |
||
684 | mysqldump -h $db_server -u $db_user -ppassword --all-databases > $d7_dir_full_backup/myassos/$current_date.d7_full.sql |
||
685 | 41 | Florent Torregrosa | </code> |
686 | </pre> |
||
687 | |||
688 | 53 | Julien Enselme | h3. d7-all-dump-individual.sh |
689 | 21 | Florent Torregrosa | |
690 | <pre> |
||
691 | 41 | Florent Torregrosa | <code class="php"> |
692 | #!/bin/sh |
||
693 | |||
694 | 21 | Florent Torregrosa | . scripts-config.sh |
695 | |||
696 | # ARGS: auto or manual |
||
697 | 1 | Julien Enselme | |
698 | 21 | Florent Torregrosa | check_arguments $# 1 |
699 | |||
700 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
701 | |||
702 | cd $d7_dir_sites |
||
703 | |||
704 | for dir in `find . -maxdepth 1 -mindepth 1 -type d ! -name all | cut -c3-` ; do |
||
705 | 1 | Julien Enselme | cd $dir |
706 | 21 | Florent Torregrosa | drush cc all |
707 | if [ $1 = 'auto' ] ; then |
||
708 | drush sql-dump --result-file="$d7_dir_individual_auto_backup/$dir/$current_date.$dir.sql" |
||
709 | else |
||
710 | 1 | Julien Enselme | drush sql-dump --result-file="$d7_dir_individual_manual_backup/$dir/$current_date.$dir.sql" |
711 | 21 | Florent Torregrosa | fi |
712 | cd - |
||
713 | done |
||
714 | </code> |
||
715 | </pre> |
||
716 | |||
717 | 53 | Julien Enselme | h3. d7-all-releases-info.sh |
718 | 21 | Florent Torregrosa | |
719 | <pre> |
||
720 | <code class="php"> |
||
721 | #!/bin/sh |
||
722 | 1 | Julien Enselme | |
723 | . scripts-config.sh |
||
724 | |||
725 | # List version of a module or theme that exists in sites/all/* |
||
726 | # and all versions that are available for same project on drupal.org |
||
727 | |||
728 | # modules |
||
729 | cd $d7_dir_sites/all/modules |
||
730 | for dir in `ls -1` ; do |
||
731 | if [ -d $dir ] ; then |
||
732 | drush pm-releases $dir |
||
733 | fi |
||
734 | done |
||
735 | |||
736 | # themes |
||
737 | cd $d7_dir_sites/all/themes |
||
738 | for dir in `ls -1` ; do |
||
739 | if [ -d $dir ] ; then |
||
740 | drush pm-releases $dir |
||
741 | fi |
||
742 | 21 | Florent Torregrosa | done |
743 | </code> |
||
744 | </pre> |
||
745 | 41 | Florent Torregrosa | |
746 | 53 | Julien Enselme | h3. d7-all-reset-variables.sh |
747 | 41 | Florent Torregrosa | |
748 | 1 | Julien Enselme | <pre> |
749 | 41 | Florent Torregrosa | <code class="php"> |
750 | #!/bin/sh |
||
751 | |||
752 | . scripts-config.sh |
||
753 | |||
754 | for dir in `find $d7_dir_sites -maxdepth 1 -mindepth 1 -type d ! -name all | sort` ; do |
||
755 | cd $dir |
||
756 | echo $dir |
||
757 | d7-reset-variables.sh |
||
758 | done |
||
759 | </code> |
||
760 | 1 | Julien Enselme | </pre> |
761 | 41 | Florent Torregrosa | |
762 | 53 | Julien Enselme | h3. d7-all-security-review.sh |
763 | 41 | Florent Torregrosa | |
764 | <pre> |
||
765 | <code class="php"> |
||
766 | 1 | Julien Enselme | #!/bin/sh |
767 | 21 | Florent Torregrosa | |
768 | . scripts-config.sh |
||
769 | |||
770 | # grep -v success to keep site_name and error lines. |
||
771 | 59 | Florent Torregrosa | bash -c "d7-all-drush.sh security-review --store |& grep -v success | mail -s d7-all-security-review.sh $email_multi_assos" |
772 | 21 | Florent Torregrosa | </code> |
773 | </pre> |
||
774 | |||
775 | 53 | Julien Enselme | h3. d7-all-update-contrib.sh |
776 | 21 | Florent Torregrosa | |
777 | <pre> |
||
778 | <code class="php"> |
||
779 | #!/bin/sh |
||
780 | |||
781 | . scripts-config.sh |
||
782 | 1 | Julien Enselme | |
783 | 21 | Florent Torregrosa | d7-all-drush.sh -y en update |
784 | # Launch cron to check for updates. |
||
785 | d7-all-drush.sh -q cron |
||
786 | |||
787 | d7-all-dump-individual.sh auto |
||
788 | |||
789 | 1 | Julien Enselme | d7-all-drush-logged.sh -y upc --no-core |
790 | 21 | Florent Torregrosa | d7-all-drush.sh -y updb |
791 | |||
792 | d7-all-drush.sh -y dis update |
||
793 | |||
794 | d7-all-drush.sh cron |
||
795 | </code> |
||
796 | 1 | Julien Enselme | </pre> |
797 | 21 | Florent Torregrosa | |
798 | 53 | Julien Enselme | h3. d7-all-update-localisation.sh |
799 | 21 | Florent Torregrosa | |
800 | <pre> |
||
801 | <code class="php"> |
||
802 | #!/bin/sh |
||
803 | |||
804 | . scripts-config.sh |
||
805 | |||
806 | d7-all-drush.sh -y en l10n_update |
||
807 | d7-all-drush.sh l10n-update-refresh |
||
808 | d7-all-drush.sh l10n-update |
||
809 | d7-all-drush.sh -y dis l10n_update |
||
810 | </code> |
||
811 | </pre> |
||
812 | 41 | Florent Torregrosa | |
813 | 53 | Julien Enselme | h3. d7-create-site.sh |
814 | 1 | Julien Enselme | |
815 | 21 | Florent Torregrosa | <pre> |
816 | <code class="php"> |
||
817 | #!/bin/sh |
||
818 | 1 | Julien Enselme | |
819 | 21 | Florent Torregrosa | . scripts-config.sh |
820 | . scripts-config-site.sh $1 |
||
821 | . scripts-utils.sh |
||
822 | |||
823 | # ARGS: site name |
||
824 | |||
825 | ######## Exceptions |
||
826 | check_arguments $# 1 |
||
827 | |||
828 | # "-" is forbidden because it provokes database error. |
||
829 | if [ `echo $1 | grep -` ] ; then |
||
830 | echo '"-" is forbidden in the site name' |
||
831 | exit 1 |
||
832 | fi |
||
833 | |||
834 | # Site name length must be lower or equal to 16 due to database limitations. |
||
835 | if [`echo $1 | wc -c` -gt 16 ] ; then |
||
836 | 41 | Florent Torregrosa | echo "site name can't have more than 16 characters" |
837 | 21 | Florent Torregrosa | exit 1 |
838 | fi |
||
839 | |||
840 | 1 | Julien Enselme | ###### Initialisation |
841 | 21 | Florent Torregrosa | cd $d7_dir |
842 | db_password=`ask_password_db $db_server $db_user` |
||
843 | site_password=`generate_password` |
||
844 | |||
845 | # Check if site database already exists. |
||
846 | if mysql -h $db_server -u $db_user -e "USE $d7_site_name" -p$db_password 2>/dev/null ; then |
||
847 | echo "Database $d7_site_name already exists" |
||
848 | exit 1 |
||
849 | fi |
||
850 | |||
851 | # Check if site folder already exists. |
||
852 | if [ -d $d7_site_dir ] ; then |
||
853 | echo "Folder $d7_site_dir already exists" |
||
854 | exit 1 |
||
855 | fi |
||
856 | |||
857 | ###### Main |
||
858 | mkdir $d7_site_dir |
||
859 | dir_site_name="assos.centrale-marseille.fr.$d7_site_name" |
||
860 | |||
861 | # Backup requirements |
||
862 | 1 | Julien Enselme | mkdir $d7_dir_individual_auto_backup/$dir_site_name |
863 | 21 | Florent Torregrosa | mkdir $d7_dir_individual_manual_backup/$dir_site_name |
864 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
865 | |||
866 | # NB : ls sort by considering the 1st characters |
||
867 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql |
||
868 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql2 |
||
869 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql3 |
||
870 | 1 | Julien Enselme | |
871 | 21 | Florent Torregrosa | # Create and grant privileges on database |
872 | mysql -h $db_server -u $db_user -e "CREATE DATABASE $d7_site_name" -p$db_password |
||
873 | mysql -h $db_server -u $db_user -e "GRANT ALL PRIVILEGES ON $d7_site_name.* TO '$d7_site_name'@'%' IDENTIFIED BY '$site_password'" -p$db_password |
||
874 | |||
875 | # Create settings.php |
||
876 | sed "s/\%\%DBUSER\%\%/$d7_site_name/ ; s/\%\%DBNAME\%\%/$d7_site_name/ ; s/\%\%DBPASS\%\%/$site_password/ ; s/\%\%nomsite\%\%/$d7_site_name/" < $d7_settings_template > $d7_site_settings |
||
877 | |||
878 | # Create symbolic link |
||
879 | cd $d7_dir |
||
880 | ln -s . $d7_site_name |
||
881 | |||
882 | # Next Instructions |
||
883 | echo "Go to http://assos.centrale-marseille.fr/$d7_site_name/install.php to continue." |
||
884 | echo "Press enter when ready to go on." |
||
885 | 1 | Julien Enselme | read key |
886 | 41 | Florent Torregrosa | |
887 | 21 | Florent Torregrosa | # Init variables |
888 | d7-reset-variables.sh $d7_site_name |
||
889 | |||
890 | # Permissions |
||
891 | chmod -R 755 $d7_site_dir |
||
892 | chmod 400 $d7_site_settings |
||
893 | |||
894 | # Last instructions |
||
895 | echo "Last instructions:" |
||
896 | echo "- Advice the webmaster to close account creation on the website" |
||
897 | echo "- Give the webmaster a link to the club Drupal's tutorials " |
||
898 | echo "- Create a node of type \"Site\" on default" |
||
899 | echo "- Register the webmaster on webmasters@listes.centrale-marseille.fr" |
||
900 | </code> |
||
901 | </pre> |
||
902 | |||
903 | 53 | Julien Enselme | h3. d7-delete-site.sh |
904 | 21 | Florent Torregrosa | |
905 | <pre> |
||
906 | <code class="php"> |
||
907 | #!/bin/sh |
||
908 | |||
909 | . scripts-config.sh |
||
910 | . scripts-config-site.sh $1 |
||
911 | . scripts-utils.sh |
||
912 | |||
913 | # ARGS: site name. |
||
914 | |||
915 | check_arguments $# 1 |
||
916 | |||
917 | db_password=`ask_password_db $db_server $db_user` |
||
918 | |||
919 | # Delete database. |
||
920 | mysql -h $db_server -u $db_user -p$db_password -e "DROP DATABASE $d7_site_name" |
||
921 | |||
922 | # Delete MYSQL user. |
||
923 | 1 | Julien Enselme | mysql -h $db_server -u $db_user -p$db_password -e "DROP USER '$d7_site_name'@'%'" |
924 | 21 | Florent Torregrosa | |
925 | # Delete site's folder. |
||
926 | chmod -R 700 $d7_site_dir |
||
927 | rm -r $d7_site_dir |
||
928 | |||
929 | 1 | Julien Enselme | # Delete symbolic link. |
930 | 21 | Florent Torregrosa | rm $d7_dir/$d7_site_name |
931 | |||
932 | # Delete database backups. |
||
933 | 1 | Julien Enselme | rm -r $d7_dir_individual_auto_backup/assos.centrale-marseille.fr.$d7_site_name |
934 | rm -r $d7_dir_individual_manual_backup/assos.centrale-marseille.fr.$d7_site_name |
||
935 | 21 | Florent Torregrosa | |
936 | echo "Don't forget to:" |
||
937 | echo "- Refresh node site on default" |
||
938 | echo "- Check particular behavior (normally detailed on site node)" |
||
939 | </code> |
||
940 | </pre> |
||
941 | |||
942 | 53 | Julien Enselme | h3. d7-reset-variables.sh |
943 | 1 | Julien Enselme | |
944 | 21 | Florent Torregrosa | <pre> |
945 | <code class="php"> |
||
946 | #!/bin/sh |
||
947 | |||
948 | . scripts-config.sh |
||
949 | |||
950 | # ARGS: [site_name] |
||
951 | |||
952 | if [ ! -z $1 ] ; then |
||
953 | . scripts-config-site.sh $1 |
||
954 | cd $d7_site_dir |
||
955 | fi |
||
956 | 1 | Julien Enselme | |
957 | 41 | Florent Torregrosa | current_timestamp=`date "+%s"` |
958 | 21 | Florent Torregrosa | |
959 | 41 | Florent Torregrosa | random_1=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "` |
960 | random_2=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "` |
||
961 | 21 | Florent Torregrosa | |
962 | ####### General variables |
||
963 | drush -y vset --always-set reverse_proxy TRUE |
||
964 | drush -y vset --always-set --format=json reverse_proxy_addresses '["147.94.19.16","147.94.19.17"]' |
||
965 | drush -y ev "variable_set('update_notify_emails', array('@email_multi_assos'));" |
||
966 | drush -y vset error_level 0 |
||
967 | drush -y vset dblog_row_limit 1000 |
||
968 | |||
969 | 1 | Julien Enselme | ###### Hidden captcha |
970 | 41 | Florent Torregrosa | drush -y en hidden_captcha |
971 | 21 | Florent Torregrosa | # Log wrong answers. |
972 | drush -y vset captcha_log_wrong_responses 1 |
||
973 | # Use hidden captcha for all forms. |
||
974 | drush -y sqlq --db-prefix "UPDATE {captcha_points} SET module = 'hidden_captcha', captcha_type = 'Hidden CAPTCHA' WHERE module is NULL;" |
||
975 | # Flush captcha cache. |
||
976 | drush -y vdel captcha_placement_map_cache |
||
977 | # Randomely generate a math question as the label of the hidden captcha field. |
||
978 | drush -y vset hidden_captcha_label "$random_1 + $random_2" |
||
979 | |||
980 | |||
981 | ####### Piwik |
||
982 | drush -y en piwik |
||
983 | drush -y vset piwik_site_id "101" |
||
984 | 41 | Florent Torregrosa | drush -y vset piwik_url_http "http://piwik.centrale-marseille.fr/" |
985 | 21 | Florent Torregrosa | drush -y vset piwik_url_https "https://piwik.centrale-marseille.fr/" |
986 | # Piwik cache. |
||
987 | drush -y vset piwik_cache 1 |
||
988 | drush -y vset piwik_visibility_roles "1" |
||
989 | # Piwik is enable for everyone except the administrator |
||
990 | drush -y vset --format=json piwik_roles '[3]' |
||
991 | drush -y vset piwik_page_title_hierarchy 1 |
||
992 | # Activate local search. |
||
993 | drush -y vset piwik_site_search 1 |
||
994 | |||
995 | |||
996 | ###### Security review |
||
997 | # For untrusted roles: |
||
998 | 41 | Florent Torregrosa | # 1: anonymous user |
999 | 21 | Florent Torregrosa | # 2: authenticated user |
1000 | # 3: administrator |
||
1001 | drush -y en security_review |
||
1002 | 11 | Julien Enselme | drush -y ev "variable_set('security_review_untrusted_roles', array('1'));" |
1003 | 54 | Florent Torregrosa | # Used to initialise entries in the database schema. |
1004 | drush security-review --store |
||
1005 | # Security review can't check for files permissions on multi_assos if launched within the web interface. |
||
1006 | drush -y sqlq --db-prefix "UPDATE {security_review} SET skip = '1', skiptime = $current_timestamp, skipuid = '1' WHERE reviewcheck IN ('file_perms');" |
||
1007 | drush -y sqlq --db-prefix "UPDATE {security_review} SET skip = '0', skiptime = '0', skipuid = NULL WHERE reviewcheck NOT IN ('file_perms');" |
||
1008 | 1 | Julien Enselme | </code> |
1009 | </pre> |