Scripts et taches planifiees » Historique » Version 68
Florent Torregrosa, 05/08/2013 20:38
crontab indentation
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 | 1 | Julien Enselme | |
31 | ### Cleaning |
||
32 | 67 | Julien Enselme | 00 5 * * * /users/guest/assos/bin/all-reset-permissions.sh > /dev/null 2>&1 |
33 | 00 6 * * * /users/guest/assos/bin/delete-temporary-files.sh > /dev/null 2>&1 |
||
34 | 1 | Julien Enselme | |
35 | |||
36 | 67 | Julien Enselme | ### Traqu-heure |
37 | 00 7 * * * /users/guest/assos/bin/traqu_heure/script-restitution.sh > /dev/null 2>&1 |
||
38 | 68 | Florent Torregrosa | 0 * * * * /users/guest/assos/bin/traqu_heure/script-traque.sh > /dev/null 2>&1 |
39 | 67 | Julien Enselme | |
40 | |||
41 | 1 | Julien Enselme | ### Databases |
42 | # Create backup |
||
43 | 67 | Julien Enselme | 00 8 1,15 * * /users/guest/assos/bin/d7-all-dump-full.sh > /dev/null 2>&1 |
44 | 68 | Florent Torregrosa | 00 1 * * 2 /users/guest/assos/bin/d6-all-dump-full.sh > /dev/null 2>&1 |
45 | 43 | Florent Torregrosa | |
46 | # flush backup |
||
47 | 67 | Julien Enselme | 00 8 2,16 * * /users/guest/assos/bin/flush-full-databases-backups.sh d7 > /dev/null 2>&1 |
48 | 68 | Florent Torregrosa | 00 22 * * 2 /users/guest/assos/bin/flush-full-databases-backups.sh d6 > /dev/null 2>&1 |
49 | 00 23 * * 2 /users/guest/assos/bin/flush-individual-databases-backups.sh auto d7 > /dev/null 2>&1 |
||
50 | 00 1 * * 3 /users/guest/assos/bin/flush-individual-databases-backups.sh manual d7 > /dev/null 2>&1 |
||
51 | 42 | Florent Torregrosa | |
52 | 43 | Florent Torregrosa | |
53 | 67 | Julien Enselme | ### Drupal 7 |
54 | 56 | Julien Enselme | 00 22 * * 3 /users/guest/assos/bin/d7-all-update-contrib.sh | mail -s "d7-all-update-contrib.sh" assos |
55 | 68 | Florent Torregrosa | 00 1 * * 4 /users/guest/assos/bin/d7-all-update-localisation.sh | mail -s "d7-all-update-localisation.sh" assos |
56 | 00 2 * * 4 /users/guest/assos/bin/d7-all-security-review.sh |
||
57 | 00 3 * * 4 /users/guest/assos/bin/d7-all-reset-variables.sh > /dev/null 2>&1 |
||
58 | 00 4 * * 4 /users/guest/assos/bin/d7-all-releases-info.sh | mail -s "d7-all-releases-info.sh" assos |
||
59 | 42 | Florent Torregrosa | |
60 | 67 | Julien Enselme | |
61 | 43 | Florent Torregrosa | ### Drupal 6 |
62 | 67 | Julien Enselme | 00 22 * * 6 /users/guest/assos/bin/d6-all-update-contrib.sh > /dev/null 2>&1 |
63 | 42 | Florent Torregrosa | 00 23 * * 6 /users/guest/assos/bin/d6-all-reset-variables.sh > /dev/null 2>&1 |
64 | 43 | Florent Torregrosa | |
65 | 67 | Julien Enselme | # Launch drush cron on fellowings |
66 | 68 | Florent Torregrosa | 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 | */10 * * * * /users/guest/assos/bin/drushcronone forum.centrale-marseille.fr > /dev/null 2>&1 |
||
72 | 67 | Julien Enselme | |
73 | 1 | Julien Enselme | 00 22 * * 7 /users/guest/assos/bin/disk-usage.sh | mail -s "disk-usage.sh" assos |
74 | </code> |
||
75 | 25 | Florent Torregrosa | </pre> |
76 | 1 | Julien Enselme | |
77 | 67 | Julien Enselme | La liste des tâches effectuées régulièrement est ci-dessous. |
78 | 3 | Julien Enselme | |
79 | 25 | Florent Torregrosa | h2. La réinitialisation des variables |
80 | |||
81 | 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. |
82 | |||
83 | 25 | Florent Torregrosa | En voici quelques exemples : |
84 | 1 | Julien Enselme | |
85 | <pre> |
||
86 | <code class="bash"> |
||
87 | 25 | Florent Torregrosa | drush -y vset error_level 0 |
88 | </code> |
||
89 | 1 | Julien Enselme | </pre> |
90 | 21 | Florent Torregrosa | |
91 | 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. |
92 | |||
93 | 3 | Julien Enselme | <pre> |
94 | 1 | Julien Enselme | <code class="php"> |
95 | drush -y vset --always-set reverse_proxy TRUE |
||
96 | 25 | Florent Torregrosa | drush -y vset --always-set --format=json reverse_proxy_addresses '["147.94.19.16","147.94.19.17"]' |
97 | 1 | Julien Enselme | </code> |
98 | 3 | Julien Enselme | </pre> |
99 | 1 | Julien Enselme | |
100 | 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** |
101 | 1 | Julien Enselme | |
102 | 6 | Julien Enselme | h2. La sauvegarde des bases de données |
103 | 1 | Julien Enselme | |
104 | 3 | Julien Enselme | Sur les installations d6 et d7 : une fois par semaine |
105 | 1 | Julien Enselme | |
106 | 3 | Julien Enselme | On utilise les [[Scripts_et_taches_planifiees#Tout-sauvegarder|scripts de sauvegarde créés par le club Drupal]]. |
107 | 1 | Julien Enselme | |
108 | 3 | Julien Enselme | h2. La purge des sauvegardes de bdd |
109 | 1 | Julien Enselme | |
110 | Sur les installations d6 et d7 : toutes les semaines |
||
111 | |||
112 | 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. |
||
113 | |||
114 | h1. Liste des scripts à disposition |
||
115 | 21 | Florent Torregrosa | |
116 | Les scripts utilisés sont hébergés dans le répertoire bin du compte assos. |
||
117 | |||
118 | 53 | Julien Enselme | h2. Configuration et utilitaires |
119 | 1 | Julien Enselme | |
120 | 53 | Julien Enselme | h3. scripts-config.sh |
121 | |||
122 | <pre> |
||
123 | <code class="php"> |
||
124 | #!/bin/sh |
||
125 | |||
126 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/users/guest/assos/bin |
||
127 | PATH=$PATH:/usr/guest/assos/bin |
||
128 | |||
129 | scripts_config='imported' |
||
130 | |||
131 | email_multi_assos="assos@centrale-marseille.fr" |
||
132 | |||
133 | dir_multi_assos='/users/guest/assos' |
||
134 | dir_scripts="$dir_multi_assos/bin" |
||
135 | dir_template="$dir_multi_assos/template" |
||
136 | |||
137 | ###### Database |
||
138 | db_server="myassos.serv.int" |
||
139 | db_user="assos" |
||
140 | dir_log="$dir_multi_assos/log" |
||
141 | |||
142 | ###### Backup |
||
143 | db_full_backup_number=3 |
||
144 | 63 | Julien Enselme | db_individual_manual_backup_number=2 |
145 | 53 | Julien Enselme | db_individual_auto_backup_number=3 |
146 | |||
147 | dir_backup="$dir_multi_assos/backup" |
||
148 | dir_full_backup="$dir_backup/full" |
||
149 | dir_individual_backup="$dir_backup/individual" |
||
150 | 1 | Julien Enselme | dir_individual_manual_backup="$dir_individual_backup/manual" |
151 | dir_individual_auto_backup="$dir_individual_backup/auto" |
||
152 | |||
153 | |||
154 | ###### D7 variables |
||
155 | d7_dir="$dir_multi_assos/htmltest" |
||
156 | d7_dir_sites="$d7_dir/sites" |
||
157 | |||
158 | ### Log |
||
159 | d7_dir_log="$dir_log/d7" |
||
160 | |||
161 | ### Backup |
||
162 | d7_dir_full_backup="$dir_full_backup/d7" |
||
163 | d7_dir_individual_manual_backup="$dir_individual_manual_backup/d7" |
||
164 | d7_dir_individual_auto_backup="$dir_individual_auto_backup/d7" |
||
165 | |||
166 | ### Template |
||
167 | d7_settings_template_name="settings-D7-bddinde-template.php" |
||
168 | d7_settings_template="$dir_template/$d7_settings_template_name" |
||
169 | |||
170 | |||
171 | ###### D6 variables |
||
172 | d6_dir="$dir_multi_assos/html" |
||
173 | d6_dir_sites="$d6_dir/sites" |
||
174 | |||
175 | ### Backup |
||
176 | d6_dir_full_backup="$dir_full_backup/d6" |
||
177 | d6_dir_individual_manual_backup="$dir_individual_manual_backup/d6" |
||
178 | d6_dir_individual_auto_backup="$dir_individual_auto_backup/d6" |
||
179 | 64 | Julien Enselme | </code> |
180 | </pre> |
||
181 | |||
182 | h3. scripts-config-site.sh |
||
183 | |||
184 | <pre> |
||
185 | <code class="php"> |
||
186 | #!/bin/sh |
||
187 | |||
188 | # Sets useful variables of a site. |
||
189 | # ARGS: site_name |
||
190 | # Requires scripts-config.sh |
||
191 | |||
192 | # Check if scripts-config.sh is imported. |
||
193 | if [ -z $scripts_config ] ; then |
||
194 | echo "Import of scripts-config.sh required." |
||
195 | exit 1 |
||
196 | fi |
||
197 | |||
198 | if [ -z $1 ] ; then |
||
199 | echo "This script needs a site name as argument." |
||
200 | exit 1 |
||
201 | fi |
||
202 | |||
203 | scripts_config_site='imported' |
||
204 | |||
205 | d7_site_name=$1 |
||
206 | d7_site_dir="$d7_dir_sites/assos.centrale-marseille.fr.$d7_site_name" |
||
207 | d7_site_settings="$d7_site_dir/settings.php" |
||
208 | 53 | Julien Enselme | </code> |
209 | </pre> |
||
210 | |||
211 | h3. scripts-utils.sh |
||
212 | |||
213 | <pre> |
||
214 | <code class="php"> |
||
215 | #!/bin/sh |
||
216 | |||
217 | # This script contains useful functions for other scripts. |
||
218 | |||
219 | # Check if scripts-config.sh is imported. |
||
220 | if [ -z $scripts_config ] ; then |
||
221 | echo "Import of scripts-config.sh required." |
||
222 | 58 | Julien Enselme | . scripts-config.sh |
223 | 53 | Julien Enselme | fi |
224 | |||
225 | scripts_utils='imported' |
||
226 | |||
227 | ask_password() { |
||
228 | # read -s doesn't work with sh. |
||
229 | # usage: pass=`ask_password "password please:"` |
||
230 | echo $1 >&2 |
||
231 | echo -n ">" >&2 |
||
232 | stty_avant=`stty -g` |
||
233 | stty -echo |
||
234 | read password |
||
235 | stty $stty_avant |
||
236 | echo "$password" |
||
237 | unset password |
||
238 | } |
||
239 | |||
240 | ask_password_db() { |
||
241 | # ARGS: server_name, user_name |
||
242 | local db_password="pour_boucler" |
||
243 | # empty db request to validate password |
||
244 | while ! mysql -h $1 -u $2 -p$db_password -e "" 2>/dev/null ; do |
||
245 | db_password=`ask_password "database password:"` |
||
246 | done |
||
247 | echo $db_password |
||
248 | } |
||
249 | |||
250 | generate_password(){ |
||
251 | # ARGS: [password_length] |
||
252 | # The password contains special characters. '/' must be excluded to avoid sed malfunction. |
||
253 | |||
254 | local site_password='/' |
||
255 | |||
256 | if [ -z $1 ] ; then |
||
257 | local password_length=20 |
||
258 | else |
||
259 | local password_length=$1 |
||
260 | fi |
||
261 | |||
262 | while echo "$site_password" | grep -Fq '/' ; do |
||
263 | site_password=`dd if=/dev/urandom count=1 | uuencode -m - | head -n 2 | tail -n 1 | cut -c-$password_length` |
||
264 | done |
||
265 | |||
266 | echo $site_password |
||
267 | } |
||
268 | |||
269 | count_d7_sites(){ |
||
270 | find $d7_dir_sites -type d ! -name all -maxdepth 1 | wc -l |
||
271 | } |
||
272 | |||
273 | check_arguments() { |
||
274 | 65 | Julien Enselme | # ARGS: number of arguments passed to script, number of arguments required, [help text] |
275 | 53 | Julien Enselme | if [ $1 -lt $2 ] ; then |
276 | 1 | Julien Enselme | echo "Number of arguments insuffisant." |
277 | 65 | Julien Enselme | echo $3 |
278 | 53 | Julien Enselme | 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 | 66 | Julien Enselme | help="# ARGS: Drupal_version, project_status, project_name\n |
329 | # List sites that have the project_name with the corresponding project_status.\n |
||
330 | # project status: enabled or disabled" |
||
331 | 21 | Florent Torregrosa | |
332 | 66 | Julien Enselme | check_arguments $# 3 "$help" |
333 | 21 | Florent Torregrosa | |
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 | 66 | Julien Enselme | help="# ARGS: number of files to keep, [email address]\n |
427 | # usage: flush files from a folder except a number equal to argument." |
||
428 | 53 | Julien Enselme | |
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 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
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 | 66 | Julien Enselme | help="# ARGS: drush_command" |
507 | 21 | Florent Torregrosa | |
508 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
509 | 21 | Florent Torregrosa | |
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 | 66 | Julien Enselme | help="# ARGS: drush_command" |
634 | 21 | Florent Torregrosa | |
635 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
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 | 66 | Julien Enselme | help="# ARGS: drush_command" |
662 | 21 | Florent Torregrosa | |
663 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
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 | 62 | Julien Enselme | . scripts-utils.sh |
696 | 21 | Florent Torregrosa | |
697 | 66 | Julien Enselme | help="# ARGS: auto or manual" |
698 | 1 | Julien Enselme | |
699 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
700 | 21 | Florent Torregrosa | |
701 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
702 | |||
703 | cd $d7_dir_sites |
||
704 | |||
705 | for dir in `find . -maxdepth 1 -mindepth 1 -type d ! -name all | cut -c3-` ; do |
||
706 | 1 | Julien Enselme | cd $dir |
707 | 21 | Florent Torregrosa | drush cc all |
708 | if [ $1 = 'auto' ] ; then |
||
709 | drush sql-dump --result-file="$d7_dir_individual_auto_backup/$dir/$current_date.$dir.sql" |
||
710 | else |
||
711 | 1 | Julien Enselme | drush sql-dump --result-file="$d7_dir_individual_manual_backup/$dir/$current_date.$dir.sql" |
712 | 21 | Florent Torregrosa | fi |
713 | cd - |
||
714 | done |
||
715 | </code> |
||
716 | </pre> |
||
717 | |||
718 | 53 | Julien Enselme | h3. d7-all-releases-info.sh |
719 | 21 | Florent Torregrosa | |
720 | <pre> |
||
721 | <code class="php"> |
||
722 | #!/bin/sh |
||
723 | 1 | Julien Enselme | |
724 | . scripts-config.sh |
||
725 | |||
726 | # List version of a module or theme that exists in sites/all/* |
||
727 | # and all versions that are available for same project on drupal.org |
||
728 | |||
729 | # modules |
||
730 | cd $d7_dir_sites/all/modules |
||
731 | for dir in `ls -1` ; do |
||
732 | if [ -d $dir ] ; then |
||
733 | drush pm-releases $dir |
||
734 | fi |
||
735 | done |
||
736 | |||
737 | # themes |
||
738 | cd $d7_dir_sites/all/themes |
||
739 | for dir in `ls -1` ; do |
||
740 | if [ -d $dir ] ; then |
||
741 | drush pm-releases $dir |
||
742 | fi |
||
743 | 21 | Florent Torregrosa | done |
744 | </code> |
||
745 | </pre> |
||
746 | 41 | Florent Torregrosa | |
747 | 53 | Julien Enselme | h3. d7-all-reset-variables.sh |
748 | 41 | Florent Torregrosa | |
749 | 1 | Julien Enselme | <pre> |
750 | 41 | Florent Torregrosa | <code class="php"> |
751 | #!/bin/sh |
||
752 | |||
753 | . scripts-config.sh |
||
754 | |||
755 | for dir in `find $d7_dir_sites -maxdepth 1 -mindepth 1 -type d ! -name all | sort` ; do |
||
756 | cd $dir |
||
757 | echo $dir |
||
758 | d7-reset-variables.sh |
||
759 | done |
||
760 | </code> |
||
761 | 1 | Julien Enselme | </pre> |
762 | 41 | Florent Torregrosa | |
763 | 53 | Julien Enselme | h3. d7-all-security-review.sh |
764 | 41 | Florent Torregrosa | |
765 | <pre> |
||
766 | <code class="php"> |
||
767 | 1 | Julien Enselme | #!/bin/sh |
768 | 21 | Florent Torregrosa | |
769 | . scripts-config.sh |
||
770 | |||
771 | # grep -v success to keep site_name and error lines. |
||
772 | 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" |
773 | 21 | Florent Torregrosa | </code> |
774 | </pre> |
||
775 | |||
776 | 53 | Julien Enselme | h3. d7-all-update-contrib.sh |
777 | 21 | Florent Torregrosa | |
778 | <pre> |
||
779 | <code class="php"> |
||
780 | #!/bin/sh |
||
781 | |||
782 | . scripts-config.sh |
||
783 | 1 | Julien Enselme | |
784 | 21 | Florent Torregrosa | d7-all-drush.sh -y en update |
785 | # Launch cron to check for updates. |
||
786 | d7-all-drush.sh -q cron |
||
787 | |||
788 | d7-all-dump-individual.sh auto |
||
789 | |||
790 | 1 | Julien Enselme | d7-all-drush-logged.sh -y upc --no-core |
791 | 21 | Florent Torregrosa | d7-all-drush.sh -y updb |
792 | |||
793 | d7-all-drush.sh -y dis update |
||
794 | |||
795 | d7-all-drush.sh cron |
||
796 | </code> |
||
797 | 1 | Julien Enselme | </pre> |
798 | 21 | Florent Torregrosa | |
799 | 53 | Julien Enselme | h3. d7-all-update-localisation.sh |
800 | 21 | Florent Torregrosa | |
801 | <pre> |
||
802 | <code class="php"> |
||
803 | #!/bin/sh |
||
804 | |||
805 | . scripts-config.sh |
||
806 | |||
807 | d7-all-drush.sh -y en l10n_update |
||
808 | d7-all-drush.sh l10n-update-refresh |
||
809 | d7-all-drush.sh l10n-update |
||
810 | d7-all-drush.sh -y dis l10n_update |
||
811 | </code> |
||
812 | </pre> |
||
813 | 41 | Florent Torregrosa | |
814 | 53 | Julien Enselme | h3. d7-create-site.sh |
815 | 1 | Julien Enselme | |
816 | 21 | Florent Torregrosa | <pre> |
817 | <code class="php"> |
||
818 | #!/bin/sh |
||
819 | 1 | Julien Enselme | |
820 | 21 | Florent Torregrosa | . scripts-config.sh |
821 | . scripts-config-site.sh $1 |
||
822 | . scripts-utils.sh |
||
823 | |||
824 | 66 | Julien Enselme | help="# ARGS: site name" |
825 | 21 | Florent Torregrosa | |
826 | ######## Exceptions |
||
827 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
828 | 21 | Florent Torregrosa | |
829 | # "-" is forbidden because it provokes database error. |
||
830 | if [ `echo $1 | grep -` ] ; then |
||
831 | echo '"-" is forbidden in the site name' |
||
832 | exit 1 |
||
833 | fi |
||
834 | |||
835 | # Site name length must be lower or equal to 16 due to database limitations. |
||
836 | if [`echo $1 | wc -c` -gt 16 ] ; then |
||
837 | 41 | Florent Torregrosa | echo "site name can't have more than 16 characters" |
838 | 21 | Florent Torregrosa | exit 1 |
839 | fi |
||
840 | |||
841 | 1 | Julien Enselme | ###### Initialisation |
842 | 21 | Florent Torregrosa | cd $d7_dir |
843 | db_password=`ask_password_db $db_server $db_user` |
||
844 | site_password=`generate_password` |
||
845 | |||
846 | # Check if site database already exists. |
||
847 | if mysql -h $db_server -u $db_user -e "USE $d7_site_name" -p$db_password 2>/dev/null ; then |
||
848 | echo "Database $d7_site_name already exists" |
||
849 | exit 1 |
||
850 | fi |
||
851 | |||
852 | # Check if site folder already exists. |
||
853 | if [ -d $d7_site_dir ] ; then |
||
854 | echo "Folder $d7_site_dir already exists" |
||
855 | exit 1 |
||
856 | fi |
||
857 | |||
858 | ###### Main |
||
859 | mkdir $d7_site_dir |
||
860 | dir_site_name="assos.centrale-marseille.fr.$d7_site_name" |
||
861 | |||
862 | # Backup requirements |
||
863 | 1 | Julien Enselme | mkdir $d7_dir_individual_auto_backup/$dir_site_name |
864 | 21 | Florent Torregrosa | mkdir $d7_dir_individual_manual_backup/$dir_site_name |
865 | current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"` |
||
866 | |||
867 | # NB : ls sort by considering the 1st characters |
||
868 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql |
||
869 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql2 |
||
870 | touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql3 |
||
871 | 1 | Julien Enselme | |
872 | 21 | Florent Torregrosa | # Create and grant privileges on database |
873 | mysql -h $db_server -u $db_user -e "CREATE DATABASE $d7_site_name" -p$db_password |
||
874 | 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 |
||
875 | |||
876 | # Create settings.php |
||
877 | 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 |
||
878 | |||
879 | # Create symbolic link |
||
880 | cd $d7_dir |
||
881 | ln -s . $d7_site_name |
||
882 | |||
883 | # Next Instructions |
||
884 | echo "Go to http://assos.centrale-marseille.fr/$d7_site_name/install.php to continue." |
||
885 | echo "Press enter when ready to go on." |
||
886 | 1 | Julien Enselme | read key |
887 | 41 | Florent Torregrosa | |
888 | 21 | Florent Torregrosa | # Init variables |
889 | d7-reset-variables.sh $d7_site_name |
||
890 | |||
891 | # Permissions |
||
892 | chmod -R 755 $d7_site_dir |
||
893 | chmod 400 $d7_site_settings |
||
894 | |||
895 | # Last instructions |
||
896 | echo "Last instructions:" |
||
897 | echo "- Advice the webmaster to close account creation on the website" |
||
898 | echo "- Give the webmaster a link to the club Drupal's tutorials " |
||
899 | echo "- Create a node of type \"Site\" on default" |
||
900 | echo "- Register the webmaster on webmasters@listes.centrale-marseille.fr" |
||
901 | </code> |
||
902 | </pre> |
||
903 | |||
904 | 53 | Julien Enselme | h3. d7-delete-site.sh |
905 | 21 | Florent Torregrosa | |
906 | <pre> |
||
907 | <code class="php"> |
||
908 | #!/bin/sh |
||
909 | |||
910 | . scripts-config.sh |
||
911 | . scripts-config-site.sh $1 |
||
912 | . scripts-utils.sh |
||
913 | |||
914 | 66 | Julien Enselme | help="# ARGS: site name." |
915 | 21 | Florent Torregrosa | |
916 | 66 | Julien Enselme | check_arguments $# 1 "$help" |
917 | 21 | Florent Torregrosa | |
918 | db_password=`ask_password_db $db_server $db_user` |
||
919 | |||
920 | # Delete database. |
||
921 | mysql -h $db_server -u $db_user -p$db_password -e "DROP DATABASE $d7_site_name" |
||
922 | |||
923 | # Delete MYSQL user. |
||
924 | 1 | Julien Enselme | mysql -h $db_server -u $db_user -p$db_password -e "DROP USER '$d7_site_name'@'%'" |
925 | 21 | Florent Torregrosa | |
926 | # Delete site's folder. |
||
927 | chmod -R 700 $d7_site_dir |
||
928 | rm -r $d7_site_dir |
||
929 | |||
930 | 1 | Julien Enselme | # Delete symbolic link. |
931 | 21 | Florent Torregrosa | rm $d7_dir/$d7_site_name |
932 | |||
933 | # Delete database backups. |
||
934 | 1 | Julien Enselme | rm -r $d7_dir_individual_auto_backup/assos.centrale-marseille.fr.$d7_site_name |
935 | rm -r $d7_dir_individual_manual_backup/assos.centrale-marseille.fr.$d7_site_name |
||
936 | 21 | Florent Torregrosa | |
937 | echo "Don't forget to:" |
||
938 | echo "- Refresh node site on default" |
||
939 | echo "- Check particular behavior (normally detailed on site node)" |
||
940 | </code> |
||
941 | </pre> |
||
942 | |||
943 | 53 | Julien Enselme | h3. d7-reset-variables.sh |
944 | 1 | Julien Enselme | |
945 | 21 | Florent Torregrosa | <pre> |
946 | <code class="php"> |
||
947 | #!/bin/sh |
||
948 | |||
949 | . scripts-config.sh |
||
950 | |||
951 | # ARGS: [site_name] |
||
952 | |||
953 | if [ ! -z $1 ] ; then |
||
954 | . scripts-config-site.sh $1 |
||
955 | cd $d7_site_dir |
||
956 | fi |
||
957 | 1 | Julien Enselme | |
958 | 41 | Florent Torregrosa | current_timestamp=`date "+%s"` |
959 | 21 | Florent Torregrosa | |
960 | 41 | Florent Torregrosa | random_1=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "` |
961 | random_2=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "` |
||
962 | 21 | Florent Torregrosa | |
963 | ####### General variables |
||
964 | drush -y vset --always-set reverse_proxy TRUE |
||
965 | drush -y vset --always-set --format=json reverse_proxy_addresses '["147.94.19.16","147.94.19.17"]' |
||
966 | drush -y ev "variable_set('update_notify_emails', array('@email_multi_assos'));" |
||
967 | drush -y vset error_level 0 |
||
968 | drush -y vset dblog_row_limit 1000 |
||
969 | |||
970 | 1 | Julien Enselme | ###### Hidden captcha |
971 | 41 | Florent Torregrosa | drush -y en hidden_captcha |
972 | 21 | Florent Torregrosa | # Log wrong answers. |
973 | drush -y vset captcha_log_wrong_responses 1 |
||
974 | # Use hidden captcha for all forms. |
||
975 | drush -y sqlq --db-prefix "UPDATE {captcha_points} SET module = 'hidden_captcha', captcha_type = 'Hidden CAPTCHA' WHERE module is NULL;" |
||
976 | # Flush captcha cache. |
||
977 | drush -y vdel captcha_placement_map_cache |
||
978 | # Randomely generate a math question as the label of the hidden captcha field. |
||
979 | drush -y vset hidden_captcha_label "$random_1 + $random_2" |
||
980 | |||
981 | |||
982 | ####### Piwik |
||
983 | drush -y en piwik |
||
984 | drush -y vset piwik_site_id "101" |
||
985 | 41 | Florent Torregrosa | drush -y vset piwik_url_http "http://piwik.centrale-marseille.fr/" |
986 | 21 | Florent Torregrosa | drush -y vset piwik_url_https "https://piwik.centrale-marseille.fr/" |
987 | # Piwik cache. |
||
988 | drush -y vset piwik_cache 1 |
||
989 | drush -y vset piwik_visibility_roles "1" |
||
990 | # Piwik is enable for everyone except the administrator |
||
991 | drush -y vset --format=json piwik_roles '[3]' |
||
992 | drush -y vset piwik_page_title_hierarchy 1 |
||
993 | # Activate local search. |
||
994 | drush -y vset piwik_site_search 1 |
||
995 | |||
996 | |||
997 | ###### Security review |
||
998 | # For untrusted roles: |
||
999 | 41 | Florent Torregrosa | # 1: anonymous user |
1000 | 21 | Florent Torregrosa | # 2: authenticated user |
1001 | # 3: administrator |
||
1002 | drush -y en security_review |
||
1003 | 11 | Julien Enselme | drush -y ev "variable_set('security_review_untrusted_roles', array('1'));" |
1004 | 54 | Florent Torregrosa | # Used to initialise entries in the database schema. |
1005 | drush security-review --store |
||
1006 | # Security review can't check for files permissions on multi_assos if launched within the web interface. |
||
1007 | drush -y sqlq --db-prefix "UPDATE {security_review} SET skip = '1', skiptime = $current_timestamp, skipuid = '1' WHERE reviewcheck IN ('file_perms');" |
||
1008 | drush -y sqlq --db-prefix "UPDATE {security_review} SET skip = '0', skiptime = '0', skipuid = NULL WHERE reviewcheck NOT IN ('file_perms');" |
||
1009 | 1 | Julien Enselme | </code> |
1010 | </pre> |