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