Projet

Général

Profil

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

root / bin / d7-delete-site.sh @ 47a400e2

1 d52a5b2f jenselme
#!/bin/sh
2
3 15ed27d8 Julien Enselme
usage() {
4
    echo "d7-delete-site.sh -s site_name."
5
}
6 d52a5b2f jenselme
7 15ed27d8 Julien Enselme
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 d52a5b2f jenselme
23 15ed27d8 Julien Enselme
. /home/assos/bin/scripts-config.sh
24 d3889c60 Julien Enselme
param="${site_name}" . /home/assos/bin/scripts-config-site.sh
25 653aeb8e Julien Enselme
. /home/assos/bin/scripts-utils.sh
26 d52a5b2f jenselme
27 64ad485a Julien Enselme
echo 'Awaiting for git status. (may take a while)'
28 683f57f9 Julien Enselme
if ! work_tree_clean ; then
29 1c1c5a42 Julien Enselme
    echo "Your work tree is not clean. Solve this before $0 can continue."
30
    exit 2
31
fi
32
33 d9dbe09c Julien Enselme
echo 'Delete database.'
34 3e9236bd Julien Enselme
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP DATABASE ${d7_site_name}"
35 d52a5b2f jenselme
36 d9dbe09c Julien Enselme
echo 'Delete MYSQL user.'
37 3e9236bd Julien Enselme
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP USER '${d7_site_name}'@'%'"
38 d52a5b2f jenselme
39 d9dbe09c Julien Enselme
echo "Delete site's folder."
40 35e0bbf4 Julien Enselme
chmod -R u=rwX,go-rwx "${d7_site_dir}"
41 3e9236bd Julien Enselme
rm -r "${d7_site_dir}"
42 d52a5b2f jenselme
43
# Delete symbolic link.
44 3e9236bd Julien Enselme
rm "${d7_dir}/${d7_site_name}"
45 d52a5b2f jenselme
46 d9dbe09c Julien Enselme
echo 'Remove site line from sites.php'
47 3e9236bd Julien Enselme
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 593e9a63 Julien Enselme
52 d9dbe09c Julien Enselme
echo 'Remove site alias from aliases.drushrc.php'
53 3e9236bd Julien Enselme
grep -sv "${d7_site_name}'" "${aliases_drushrc_php}" > "${dir_tmp}/aliases.php"
54
mv "${dir_tmp}/aliases.php" "${aliases_drushrc_php}"
55 0e4152d9 Julien Enselme
56 d9dbe09c Julien Enselme
echo 'Delete database backups.'
57 3e9236bd Julien Enselme
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 d52a5b2f jenselme
60 bf546089 Julien Enselme
echo 'Remove site from nginx_map'
61 5fbc698e Julien Enselme
d7-generate-nginx-map.sh
62 73a967a6 Julien Enselme
# Restart nginx
63 be524722 Julien Enselme
sudo service nginx restart
64 0f75e6b1 Julien Enselme
65 d52a5b2f jenselme
echo "Don't forget to:"
66
echo "- Refresh node site on default"
67
echo "- Check particular behavior (normally detailed on site node)"
68 1c1c5a42 Julien Enselme
69 3e9236bd Julien Enselme
commit "Deletion of site: ${d7_site_name}"