Projet

Général

Profil

Paste
Télécharger (1,78 ko) Statistiques
| Branche: | Révision:

root / bin / d7-delete-site.sh @ 1900469e

1
#!/bin/sh
2

    
3
usage() {
4
    echo "d7-delete-site.sh -s site_name."
5
}
6

    
7
site_name=''
8
while getopts "hs:" opt; do
9
    case "${opt}" in
10
	h)
11
	    usage; exit 0;;
12
	s)
13
	    site_name="${OPTARG}";;
14
	:)
15
	    echo "Option -$OPTARG requires an argument." >&2
16
	    usage >&2; exit 1;;
17
	\?)
18
	    usage >&2; exit 1;;
19
    esac
20
done
21
shift $((OPTIND-1))
22

    
23
. /home/assos/bin/scripts-config.sh
24
. scripts-config-site.sh "${site_name}"
25
. scripts-utils.sh
26

    
27
echo 'Awaiting for git status. (may take a while)'
28
if ! work_tree_clean ; then
29
    echo "Your work tree is not clean. Solve this before $0 can continue."
30
    exit 2
31
fi
32

    
33
echo 'Delete database.'
34
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP DATABASE ${d7_site_name}"
35

    
36
echo 'Delete MYSQL user.'
37
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP USER '${d7_site_name}'@'%'"
38

    
39
echo "Delete site's folder."
40
chmod -R 700 "${d7_site_dir}"
41
rm -r "${d7_site_dir}"
42

    
43
# Delete symbolic link.
44
rm "${d7_dir}/${d7_site_name}"
45

    
46
echo 'Remove site line from sites.php'
47
chmod +w "${sites_php}"
48
grep -sv "^\$.*$d7_site_name';$" "${sites_php}" > "${dir_tmp}/sites.php"
49
mv "${dir_tmp}/sites.php" "${sites_php}"
50
chmod 400 "${sites_php}"
51

    
52
echo 'Remove site alias from aliases.drushrc.php'
53
grep -sv "${d7_site_name}'" "${aliases_drushrc_php}" > "${dir_tmp}/aliases.php"
54
mv "${dir_tmp}/aliases.php" "${aliases_drushrc_php}"
55

    
56
echo 'Delete database backups.'
57
rm -r "${d7_dir_individual_auto_backup}/assos.centrale-marseille.fr.${d7_site_name}"
58
rm -r "${d7_dir_individual_manual_backup}/assos.centrale-marseille.fr.${d7_site_name}"
59

    
60
echo 'Remove site from nginx_map'
61
d7-generate-nginx-map.sh
62
# Restart nginx
63
sudo service nginx restart
64

    
65
echo "Don't forget to:"
66
echo "- Refresh node site on default"
67
echo "- Check particular behavior (normally detailed on site node)"
68

    
69
commit "Deletion of site: ${d7_site_name}"