-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathreconfigure.sh
49 lines (36 loc) · 1.2 KB
/
reconfigure.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
#!/bin/bash
# Reconfigures SuperAdmin from/to HTTPs
# $1 = SuperAdmin via HTTPS (y/n)
# $2 = Domain name without protocol (e.g. superadmin.yourdomain.com)
# $3 = Generate new SSL (y/n)
repexp=s/#domain#/$2/g
httpenexp=s/#disablehttp#//g
httpsenexp=s/#disablehttps#//g
cp /www/superadmin/superadmin.conf /www/nginx/
if [ "$1" == "n" ]; then
sed -i -e $httpenexp /www/nginx/superadmin.conf
sed -i -e $repexp /www/nginx/superadmin.conf
nginx -s reload
echo "Configured superadmin with http://$2"
else
if [ "$3" == "y" ]; then
# ensure it's not configured with ssl
sed -i -e $repexp /www/nginx/superadmin.conf
sed -i -e $httpenexp /www/nginx/superadmin.conf
nginx -s reload
# Generates SSL
echo "Generating SSL ..."
bash /www/superadmin/ssl.sh $2
fi
if [ -f "/www/ssl/$2/fullchain.cer" ]; then
# copy it again to it's reconfigured with ssl
cp /www/superadmin/superadmin.conf /www/nginx/
sed -i -e $httpsenexp /www/nginx/superadmin.conf
sed -i -e $repexp /www/nginx/superadmin.conf
nginx -s reload
echo "Configured superadmin with https://$2"
else
echo "Failed to reconfigure with HTTPS properly, '/www/ssl/$2/fullchain.cer' not found..." 2>&1
fi
fi
/bin/bash /www/superadmin/run.sh