Skip to content

Commit 269807c

Browse files
author
Kristan Kenney
committed
Add HSTS enablement function to upgrade process
1 parent 7883f33 commit 269807c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

install/upgrade/0.9.8-28.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
HESTIA="/usr/local/hestia"
33
HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
4+
spinner="/-\|"
45

56
# load hestia.conf
67
source $HESTIA/conf/hestia.conf
@@ -71,6 +72,28 @@ if [ ! -z "$BACKEND_PORT" ]; then
7172
/usr/local/hestia/bin/v-change-sys-port $BACKEND_PORT
7273
fi
7374

75+
# Generating dhparam.
76+
if [ -z /etc/ssl/dhparam.pem ]; then
77+
echo "(*) Enabling HTTPS Strict Transport Security (HSTS) support"
78+
echo -n " This will take some time, please wait..."
79+
openssl dhparam 4096 -out /etc/ssl/dhparam.pem > /dev/null 2>&1 &
80+
BACK_PID=$!
81+
82+
# Check if package installation is done, print a spinner
83+
spin_i=1
84+
while kill -0 $BACK_PID > /dev/null 2>&1 ; do
85+
printf "\b${spinner:spin_i++%${#spinner}:1}"
86+
sleep 0.5
87+
done
88+
89+
# Do a blank echo to get the \n back
90+
echo
91+
92+
# Update dns servers in nginx.conf
93+
dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
94+
sed -i "s/1.0.0.1 1.1.1.1/$dns_resolver/g" /etc/nginx/nginx.conf
95+
fi
96+
7497
# Update default page templates
7598
echo "(*) Replacing default templates and packages..."
7699
echo " Existing templates have been backed up to the following location:"

0 commit comments

Comments
 (0)