Révision 5b5ea032
Ajouté par Julien Enselme il y a environ 10 ans
other-scripts/d7-sync.sh | ||
---|---|---|
1 |
#!/usr/bin/bash |
|
2 |
|
|
3 |
help=<<EOF |
|
4 |
This script is intended to ease the synchronisation of any site hosted by assos. It relies on bash, drush and requires @ssh assos@ to work. |
|
5 |
The drupal installation is synched using git, the website files and database using rsync. |
|
6 |
|
|
7 |
usage: d7-sync.sh [SITENAME] |
|
8 |
If a sitename is provided, the script will sync the drupal installation and the sites' |
|
9 |
folders and database. Othewise, only the drupal installation is synched. |
|
10 |
|
|
11 |
You must launch this script at the root of the drupal instance. |
|
12 |
EOF |
|
13 |
|
|
14 |
# sync drupal tree |
|
15 |
git pull --rebase |
|
16 |
|
|
17 |
# sync files |
|
18 |
if [ -z "$1" ] ; then |
|
19 |
exit 0 |
|
20 |
fi |
|
21 |
|
|
22 |
cd htmltest/sites |
|
23 |
if [ $1 = default ] ; then |
|
24 |
dir_site=$1 |
|
25 |
else |
|
26 |
dir_site=assos.centrale-marseille.fr.$1 |
|
27 |
fi |
|
28 |
mkdir $dir_site |
|
29 |
cd $dir_site |
|
30 |
rsync -rl --progress assos:~/htmltest/sites/$dir_site/* . |
|
31 |
|
|
32 |
# sync databases |
|
33 |
now=$(date +%s) |
|
34 |
sql_file="$1.$now.sql" |
|
35 |
remote_sql_file="~/tmp/$sql_file" |
|
36 |
ssh assos "drush @$1 sql-dump > $remote_sql_file" |
|
37 |
scp assos:$remote_sql_file . |
|
38 |
mysql -u root -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1" |
|
39 |
mysql -u root $1 < $sql_file |
|
40 |
rm $sql_file |
|
41 |
ssh assos "rm $remote_sql_file" |
|
42 |
|
|
43 |
# modify settings.php |
|
44 |
|
|
45 |
# various drush cmd to finish synchronisation |
|
46 |
drush -y dis piwik |
|
47 |
drush -y vset maintenace_mode 0 |
|
48 |
drush -y vset error_level 2 |
|
49 |
drush cc all |
Formats disponibles : Unified diff
Sync everything. TODO: settings.php modification.