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