Projet

Général

Profil

Révision 8550e097

Ajouté par Julien Enselme il y a plus de 9 ans

Command subsitution are not quoted. Quotes posed problems in loop.

Voir les différences:

bin/all-reset-permissions.sh
5 5
# This script puts the correct permissions to sites folders, settings.php and scripts.
6 6

  
7 7
######### drupal 7
8
for dir in "$(find "${d7_dir_sites}" -type d -maxdepth 1 -mindepth 1 ! -name all)" ; do
8
for dir in $(find "${d7_dir_sites}" -type d -maxdepth 1 -mindepth 1 ! -name all); do
9 9
    chmod 755 "${dir}"
10 10
    chmod 400 "${dir}/settings.php"
11 11
    chmod 400 "${dir}/settings.local.php"
bin/d7-all-drush.sh
7 7

  
8 8
check_arguments "$#" 1 "${help}"
9 9

  
10
for dir in "$(find "${d7_dir_sites}" -maxdepth 1 -mindepth 1 -type d ! -name all | sort)" ; do
10
for dir in $(find "${d7_dir_sites}" -maxdepth 1 -mindepth 1 -type d ! -name all | sort) ; do
11 11
    cd "${dir}"
12 12
    echo "${dir}"
13 13
    drush "$@"
bin/d7-all-dump-full.sh
3 3
. /home/assos/bin/scripts-config.sh
4 4
. /home/assos/bin/scripts-utils.sh
5 5

  
6
current_date="$(date "+%Y-%m-%d-%Hh%Mm%Ss")"
6
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss")
7 7

  
8 8
# Dump D7 databases at once.
9 9
mysqldump --defaults-extra-file="${myassos_cnf}" --all-databases | gzip > "${d7_dir_full_backup}/myassos/${current_date}.d7_full.sql.gz"
bin/d7-all-dump-individual.sh
7 7

  
8 8
check_arguments "$#" 1 "$help"
9 9

  
10
current_date="$(date "+%Y-%m-%d-%Hh%Mm%Ss")"
10
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss")
11 11

  
12 12
cd "${d7_dir_sites}"
13 13

  
14
for dir in "$(find . -maxdepth 1 -mindepth 1 -type d ! -name all | cut -c3-)" ; do
14
for dir in $(find . -maxdepth 1 -mindepth 1 -type d ! -name all | cut -c3-); do
15 15
    cd "${dir}"
16 16
    drush cc all
17 17
    if [ "$1" = 'auto' ] ; then
bin/d7-all-releases-info.sh
7 7

  
8 8
# modules
9 9
cd "${d7_dir_sites}/all/modules"
10
for dir in "$(ls -1)" ; do
10
for dir in $(ls -1) ; do
11 11
    if [ -d "${dir}" ] ; then
12 12
        drush pm-releases "${dir}"
13 13
    fi
......
15 15

  
16 16
# themes
17 17
cd "${d7_dir_sites}/all/themes"
18
for dir in "$(ls -1)" ; do
18
for dir in $(ls -1) ; do
19 19
    if [ -d "${dir}" ] ; then
20 20
        drush pm-releases "${dir}"
21 21
    fi
bin/d7-all-reset-variables.sh
2 2

  
3 3
. /home/assos/bin/scripts-config.sh
4 4

  
5
for dir in "$(find "${d7_dir_sites}" -maxdepth 1 -mindepth 1 -type d ! -name all | sort)" ; do
5
for dir in $(find "${d7_dir_sites}" -maxdepth 1 -mindepth 1 -type d ! -name all | sort); do
6 6
    echo "${dir}"
7
    site_name="$(echo "${dir}" | tr '.' '\n' | tail -n 1)"
7
    site_name=$(echo "${dir}" | tr '.' '\n' | tail -n 1)
8 8
    d7-reset-variables.sh "${site_name}"
9 9
done
bin/d7-all-update-core.sh
30 30
# Get the new subversion number:
31 31
# cd to $d7_dir, filter drush status to get the drupal version line,
32 32
# remove end line whitespaces, and get the 2 last caracters of the string.
33
drupal_version="$(cd "${d7_dir}" && drush status | grep "Drupal version" | tr -d ' ' | tail -c 3)"
33
drupal_version=$(cd "${d7_dir}" && drush status | grep "Drupal version" | tr -d ' ' | tail -c 3)
34 34

  
35 35
# Try to download new translation. If it fails, restore the old one.
36 36
if ! curl -f "http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.${drupal_version}.fr.po" -o "${translations_fr}" ; then
bin/d7-all-update-settings.sh
5 5

  
6 6
# This script updates all drupal 7 settings.php according to a new template. Site informations located in settings.local.php are left intact.
7 7

  
8
for settings in "$(find "${d7_dir_sites}" -mindepth 2 -maxdepth 2 -name settings.php)" ; do
8
for settings in $(find "${d7_dir_sites}" -mindepth 2 -maxdepth 2 -name settings.php); do
9 9

  
10 10
    # We go into the settings.php directory.
11
    settings_dir="$(give_dir "${settings}")"
11
    settings_dir=$(give_dir "${settings}")
12 12
    cd "${settings_dir}"
13 13

  
14 14
    chmod 700 "${settings}"
bin/d7-all-usage.sh
6 6

  
7 7
cd "${d7_dir_sites}"
8 8

  
9
for line in "$(drush pml --no-core --pipe)"; do
9
for line in $(drush pml --no-core --pipe); do
10 10
    usage.sh d7 enabled "${line}"
11 11
    echo -e "\n"
12 12
done
bin/d7-create-site.sh
26 26
fi
27 27

  
28 28
# "-" is forbidden because it provokes database error.
29
if [ "$(echo "$1" | grep -)" ] ; then
29
if [ $(echo "$1" | grep -) ] ; then
30 30
    echo '"-" is forbidden in the site name'
31 31
    exit 1
32 32
fi
33 33

  
34 34
# Site name length must be lower or equal to 16 due to database limitations.
35
if [ "$(echo "$1" | wc -c)" -gt 16 ] ; then
35
if [ $(echo "$1" | wc -c) -gt 16 ] ; then
36 36
    echo "site name can't have more than 16 characters"
37 37
    exit 1
38 38
fi
......
45 45

  
46 46
###### Initialisation
47 47
cd "${d7_dir}"
48
site_password="$(generate_password)"
48
site_password=$(generate_password)
49 49
site_line_sites_php="\$sites['assos.centrale-marseille.fr.$d7_site_name'] = 'assos.centrale-marseille.fr.$d7_site_name';"
50 50
site_line_aliases_drushrc_php="\$aliases['$d7_site_name'] = array('uri' => 'assos.centrale-marseille.fr/$d7_site_name', 'root' => '/home/assos/drupal7/', );"
51 51
# NB: site_name is initialised in script-config-site.sh
......
60 60
# Backup requirements
61 61
mkdir "${d7_dir_individual_auto_backup}/${dir_site_name}"
62 62
mkdir "${d7_dir_individual_manual_backup}/${dir_site_name}"
63
current_date="$(date "+%Y-%m-%d-%Hh%Mm%Ss")"
63
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss")
64 64

  
65 65
# NB : ls sort by considering the 1st characters
66 66
touch "${d7_dir_individual_auto_backup}/${dir_site_name}/${current_date}.${dir_site_name}.sql"
bin/d7-reset-variables.sh
14 14
    fi
15 15
fi
16 16

  
17
current_timestamp="$(date "+%s")"
17
current_timestamp=$(date "+%s")
18 18

  
19
random_1="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")"
20
random_2="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")"
19
random_1=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
20
random_2=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
21 21

  
22 22
####### General variables
23 23
drush -yq vset --always-set reverse_proxy TRUE
bin/d7-sync-site.sh
27 27

  
28 28

  
29 29
# Backup the database of SOURCE_SITE
30
current_date="$(date "+%Y-%m-%d-%Hh%Mm%Ss")"
30
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss")
31 31
if [ "$1" = "default" ] ; then
32 32
    dir="$2"
33 33
else
......
45 45
# Sync databases
46 46
## Save file system
47 47
if [ -z "${new_site}" ] ; then
48
    private_path="$(drush "@$2" vget --format=string file_private_path 2> /dev/null)"
49
    public_path="$(drush "@$2" vget --format=string file_public_path 2> /dev/null)"
50
    temp_path="$(drush "@$2" vget --format=string file_temporary_path 2> /dev/null)"
48
    private_path=$(drush "@$2" vget --format=string file_private_path 2> /dev/null)
49
    public_path=$(drush "@$2" vget --format=string file_public_path 2> /dev/null)
50
    temp_path=$(drush "@$2" vget --format=string file_temporary_path 2> /dev/null)
51 51
fi
52 52

  
53 53
## Sync
54
current_date="$(date "+%Y-%m-%d-%Hh%Mm%Ss")"
54
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss")
55 55
sql_file="${dir_tmp}/${current_date}.$1.sql"
56 56
drush -y "@$1" sql-dump --result-file="${sql_file}"
57 57
sed -i -e "s#https?://assos.centrale-marseille.fr/$1#https://assos.centrale-marseille.fr/$2#g" "${sql_file}"
bin/flush-files.sh
21 21
    ls | head "-${number_of_backups_to_delete}" | xargs rm
22 22
else
23 23
    if [ ! -z "$2" ] ; then
24
        dir="$(pwd)"
24
        dir=$(pwd)
25 25
        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"
26 26
    fi
27 27
fi
bin/flush-full-databases-backups.sh
6 6

  
7 7
cd "${dir_full_backup}/$1"
8 8

  
9
for dir in "$(ls)" ; do
9
for dir in $(ls) ; do
10 10
    cd "${dir}"
11 11
    flush-files.sh "${db_full_backup_number}" "${email_multi_assos}"
12 12
    cd -
bin/flush-individual-databases-backups.sh
6 6

  
7 7
cd "${dir_individual_backup}/$1/$2"
8 8

  
9
for dir in "$(ls)" ; do
9
for dir in $(ls) ; do
10 10
    cd "${dir}"
11
    if [ $1 = 'auto' ] ; then
11
    if [ "$1" = 'auto' ] ; then
12 12
        flush-files.sh "${db_individual_auto_backup_number}" "${email_multi_assos}"
13 13
    else
14 14
        flush-files.sh "${db_individual_manual_backup_number}"
bin/scripts-utils.sh
36 36
    fi
37 37

  
38 38
    while echo "$site_password" | grep -Fq '/' ; do
39
        site_password="$(dd if=/dev/random count=1 | uuencode -m - | head -n 2 | tail -n 1 | cut -c-"${password_length}")"
39
        site_password=$(dd if=/dev/random count=1 | uuencode -m - | head -n 2 | tail -n 1 | cut -c-"${password_length}")
40 40
    done
41 41

  
42 42
    echo "$site_password"
......
63 63
give_dir() {
64 64
    # ARG: file
65 65
    # Return the abosulte directory path of a file or a dir.
66
    settings_location="$(realpath "$1")"
67
    echo "$(dirname "${settings_location}")"
66
    settings_location=$(realpath "$1")
67
    echo $(dirname "${settings_location}")
68 68
}
69 69

  
70 70
work_tree_clean() {
71
    git_status_output="$(git status --porcelain)"
71
    git_status_output=$(git status --porcelain)
72 72
    if [ -z "${git_status_output}" ] ; then
73 73
	return 0
74 74
    else
......
77 77
}
78 78

  
79 79
mail_unclean_work_tree() {
80
    cd "$dir_multi_assos"
81
    git_status_output="$(git status)"
80
    cd "${dir_multi_assos}"
81
    git_status_output=$(git status)
82 82
    echo "${git_status_output}" | mail -s "$1" "${email_multi_assos}"
83 83
}
84 84

  
bin/usage.sh
17 17

  
18 18
number_found=0
19 19

  
20
for dir in "$(find . -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort)" ; do
20
for dir in $(find . -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort) ; do
21 21
    # List projects that correspond to the status.
22 22
    # Keep project_name if listed.
23 23
    # Count line result. 0 if not listed or 1 if listed.
24 24
    # Print site_dir if listed.
25 25

  
26 26
    cd "${dir}";
27
	if [ 1 -le "$(drush pml --status="$2" | grep "$3" | wc -l)" ] ; then
27
	if [ 1 -le $(drush pml --status="$2" | grep "$3" | wc -l) ] ; then
28 28
        echo "${dir}";
29 29
        number_found=$(($number_found + 1))
30 30
    fi
other-scripts/d7-sync.sh
60 60

  
61 61

  
62 62
### sync databases
63
now="$(date +%s)"
63
now=$(date +%s)
64 64
sql_file="$1.${now}.sql"
65 65
remote_sql_file="${REMOTE_DIR_TMP_SAS}/${sql_file}"
66 66
ssh "${WEBASSOS_ID}" "drush @$1 sql-dump > ${remote_sql_file}"

Formats disponibles : Unified diff