Project

General

Profile

Paste
Download (1.51 KB) Statistics
| Branch: | Revision:

root / bin / d7-delete-site.sh @ 73a967a6

1 d52a5b2f jenselme
#!/bin/sh
2
3 06e9d071 Assos Assos
. /home/assos/bin/scripts-config.sh
4 3e9236bd Julien Enselme
. scripts-config-site.sh "$1"
5 d52a5b2f jenselme
. scripts-utils.sh
6
7
help="# ARGS: site name."
8
9 3e9236bd Julien Enselme
check_arguments "$#" 1 "${help}"
10 d52a5b2f jenselme
11 64ad485a Julien Enselme
echo 'Awaiting for git status. (may take a while)'
12 683f57f9 Julien Enselme
if ! work_tree_clean ; then
13 1c1c5a42 Julien Enselme
    echo "Your work tree is not clean. Solve this before $0 can continue."
14
    exit 2
15
fi
16
17 d9dbe09c Julien Enselme
echo 'Delete database.'
18 3e9236bd Julien Enselme
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP DATABASE ${d7_site_name}"
19 d52a5b2f jenselme
20 d9dbe09c Julien Enselme
echo 'Delete MYSQL user.'
21 3e9236bd Julien Enselme
mysql --defaults-extra-file="${myassos_cnf}" -e "DROP USER '${d7_site_name}'@'%'"
22 d52a5b2f jenselme
23 d9dbe09c Julien Enselme
echo "Delete site's folder."
24 3e9236bd Julien Enselme
chmod -R 700 "${d7_site_dir}"
25
rm -r "${d7_site_dir}"
26 d52a5b2f jenselme
27
# Delete symbolic link.
28 3e9236bd Julien Enselme
rm "${d7_dir}/${d7_site_name}"
29 d52a5b2f jenselme
30 d9dbe09c Julien Enselme
echo 'Remove site line from sites.php'
31 3e9236bd Julien Enselme
chmod +w "${sites_php}"
32
grep -sv "^\$.*$d7_site_name';$" "${sites_php}" > "${dir_tmp}/sites.php"
33
mv "${dir_tmp}/sites.php" "${sites_php}"
34
chmod 400 "${sites_php}"
35 593e9a63 Julien Enselme
36 d9dbe09c Julien Enselme
echo 'Remove site alias from aliases.drushrc.php'
37 3e9236bd Julien Enselme
grep -sv "${d7_site_name}'" "${aliases_drushrc_php}" > "${dir_tmp}/aliases.php"
38
mv "${dir_tmp}/aliases.php" "${aliases_drushrc_php}"
39 0e4152d9 Julien Enselme
40 d9dbe09c Julien Enselme
echo 'Delete database backups.'
41 3e9236bd Julien Enselme
rm -r "${d7_dir_individual_auto_backup}/assos.centrale-marseille.fr.${d7_site_name}"
42
rm -r "${d7_dir_individual_manual_backup}/assos.centrale-marseille.fr.${d7_site_name}"
43 d52a5b2f jenselme
44 bf546089 Julien Enselme
echo 'Remove site from nginx_map'
45 5fbc698e Julien Enselme
d7-generate-nginx-map.sh
46 73a967a6 Julien Enselme
# Restart nginx
47
#sudo service nginx reload
48 0f75e6b1 Julien Enselme
49 d52a5b2f jenselme
echo "Don't forget to:"
50
echo "- Refresh node site on default"
51
echo "- Check particular behavior (normally detailed on site node)"
52 1c1c5a42 Julien Enselme
53 3e9236bd Julien Enselme
commit "Deletion of site: ${d7_site_name}"