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