-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveClient.sh
More file actions
executable file
·71 lines (63 loc) · 1.39 KB
/
removeClient.sh
File metadata and controls
executable file
·71 lines (63 loc) · 1.39 KB
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
65
66
67
68
69
70
71
#!/bin/bash
if [ $# -lt 1 ]
then
echo Not enough args
exit 1
fi
#-----------------------------------------
PATH=/opt/odoo-multi/bin:$PATH
. config.sh
unset LANG
if ! [ -d $WORK ]
then
echo Cannot find $WORK. Exiting...
exit 1
fi
for OPT in $@
do
if [ $OPT = "-y" ]
then
RESP=Y
fi
done
while [ -z "$RESP" ]
do
echo -n "You are about to complete remove $CLIENT. Are you sure?? (Y/n)"
read RESP
[ -z "$RESP" ] && continue
if [ "$RESP" == "Y" ] || [ "$RESP" == "y" ]
then
echo "OK. Continuing"
else
echo "Aborting..."
exit 2
fi
done
#-----------------------------------------
sudo systemctl stop odoo_${CLIENT}
if [ $? -ne 0 ]
then
echo "could not stop odoo_${CLIENT}"
exit 3
fi
sudo systemctl disable odoo_${CLIENT} > /dev/null
if [ -e /lib/systemd/system/odoo_${CLIENT}.service ]
then
sudo rm /lib/systemd/system/odoo_${CLIENT}.service
fi
sudo systemctl daemon-reload > /dev/null
sudo systemctl reset-failed > /dev/null
dropdb $CLIENT
if [ $? -eq 0 ]
then
if grep ssl_certificate_key /etc/nginx/sites-available/${CLIENT}.conf > /dev/null
then
sudo certbot delete --cert-name ${CLIENT}.$DOMAIN
fi
sudo rm -rf $WORK
sudo rm /etc/nginx/sites-{enabled,available}/${CLIENT}.conf
sudo systemctl reload nginx
else
echo "Warning: Service removed but could not drop database."
exit 4
fi