Skip to content

Commit 392baf2

Browse files
authored
Fix bug when no ipv6 is availble with hestia-nginx install or upgrade (hestiacp#4541)
* Drop CMP check * Create a Pre install script to create backup of existing config
1 parent 7aa3ef4 commit 392baf2

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

func/syshealth.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -614,23 +614,17 @@ function syshealth_adapt_hestia_nginx_listen_ports() {
614614
done
615615

616616
# Adapt port listing in nginx.conf depended on availability of IPV4 and IPV6 network interface
617-
NGINX_BCONF_CHANGED=""
618-
NGINX_BCONF="/usr/local/hestia/nginx/conf/nginx.conf"
619-
NGINX_BCONF_TEMP="/tmp/nginx.conf"
620-
cp "$NGINX_BCONF" "$NGINX_BCONF_TEMP"
617+
NGINX_CONF="/usr/local/hestia/nginx/conf/nginx.conf"
621618
if [ -z "$ipv4_scope_global" ]; then
622-
sed -i 's/^\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/#\1/' "$NGINX_BCONF"
619+
sed -i 's/^\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/#\1/' "$NGINX_CONF"
623620
else
624-
sed -i 's/#\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/\1/' "$NGINX_BCONF"
621+
sed -i 's/#\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/\1/' "$NGINX_CONF"
625622
fi
626623
if [ -z "$ipv6_scope_global" ]; then
627-
sed -i 's/^\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/#\1/' "$NGINX_BCONF"
624+
sed -i 's/^\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/#\1/' "$NGINX_CONF"
628625
else
629-
sed -i 's/#\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/\1/' "$NGINX_BCONF"
626+
sed -i 's/#\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/\1/' "$NGINX_CONF"
630627
fi
631-
cmp --silent "$NGINX_BCONF" "$NGINX_BCONF_TEMP"
632-
[ $? -ne 0 ] && NGINX_BCONF_CHANGED="yes"
633-
rm -f "$NGINX_BCONF_TEMP" > /dev/null 2>&1
634628
}
635629

636630
syshealth_adapt_nginx_resolver() {

src/deb/nginx/preinst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Run triggers only on updates
4+
if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
5+
exit
6+
fi
7+
8+
# Create a new Backup folder
9+
HESTIA_BACKUP="/root/hst_nginx_backups/$(date +%d%m%Y%H%M)"
10+
mkdir -p HESTIA_BACKUP
11+
12+
# Create a backup of the current configuration
13+
cp -r /usr/local/hestia/nginx/conf/nginx.conf $HESTIA_BACKUP/nginx.conf
14+
15+
exit

0 commit comments

Comments
 (0)