-
Notifications
You must be signed in to change notification settings - Fork 0
/
del-domain.sh
executable file
·64 lines (51 loc) · 1.58 KB
/
del-domain.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
#################################################
# Setup debian-9 to serve django project
# For debian-9 instance at aws-lightsail
# [email protected] - 27/May/2020
#################################################
clear
echo "#################################################"
echo "# Removing Domain"
# Color Variable
Gre='\033[0;32m'; # Green
NoC='\033[0m'; # No Color
# Make commands invokes serially
set -euo pipefail
#################################################
# Get domain data
if [ -z ${1+x} ]; then
echo -e -n "${Gre}"
read -p "Domain to remove: " DOMAIN
echo -e -n "${NoC}"
else
DOMAIN=$1
fi
SANITIZED_DOMAIN=${DOMAIN/./_}
#################################################
# Cleanup supervisor
# Removing supervisor conf script
echo '> Removing Supervisor Conf Script'
sudo supervisorctl stop $SANITIZED_DOMAIN
sudo rm /etc/supervisor/conf.d/${SANITIZED_DOMAIN}.conf
# Reread & update supervisor to remove apps
sudo supervisorctl reread
sudo supervisorctl update
#################################################
# Deleting user
echo '> Deleting User'
sudo userdel $SANITIZED_DOMAIN
sudo rm -rf /webapps/${SANITIZED_DOMAIN}__django
#################################################
# Cleanup web server
echo '> Removing Nginx Entry'
# Removing nginx entry
sudo rm -rf /etc/nginx/sites-enabled/$DOMAIN
sudo rm -rf /etc/nginx/sites-available/$DOMAIN
#################################################
# Deleting domain conf direktori
echo '> Deleting Domain Direktori'
rm -rf $DOMAIN
# Restart nginx
echo '> Restarting nginx'
sudo service nginx restart