소스 검색

Fix bug when no ipv6 is availble with hestia-nginx install or upgrade (#4541)

* Drop CMP check

* Create a Pre install script to create backup of existing config
Jaap Marcus 1 년 전
부모
커밋
392baf224f
2개의 변경된 파일20개의 추가작업 그리고 11개의 파일을 삭제
  1. 5 11
      func/syshealth.sh
  2. 15 0
      src/deb/nginx/preinst

+ 5 - 11
func/syshealth.sh

@@ -614,23 +614,17 @@ function syshealth_adapt_hestia_nginx_listen_ports() {
 	done
 
 	# Adapt port listing in nginx.conf depended on availability of IPV4 and IPV6 network interface
-	NGINX_BCONF_CHANGED=""
-	NGINX_BCONF="/usr/local/hestia/nginx/conf/nginx.conf"
-	NGINX_BCONF_TEMP="/tmp/nginx.conf"
-	cp "$NGINX_BCONF" "$NGINX_BCONF_TEMP"
+	NGINX_CONF="/usr/local/hestia/nginx/conf/nginx.conf"
 	if [ -z "$ipv4_scope_global" ]; then
-		sed -i 's/^\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/#\1/' "$NGINX_BCONF"
+		sed -i 's/^\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/#\1/' "$NGINX_CONF"
 	else
-		sed -i 's/#\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/\1/' "$NGINX_BCONF"
+		sed -i 's/#\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/\1/' "$NGINX_CONF"
 	fi
 	if [ -z "$ipv6_scope_global" ]; then
-		sed -i 's/^\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/#\1/' "$NGINX_BCONF"
+		sed -i 's/^\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/#\1/' "$NGINX_CONF"
 	else
-		sed -i 's/#\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/\1/' "$NGINX_BCONF"
+		sed -i 's/#\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/\1/' "$NGINX_CONF"
 	fi
-	cmp --silent "$NGINX_BCONF" "$NGINX_BCONF_TEMP"
-	[ $? -ne 0 ] && NGINX_BCONF_CHANGED="yes"
-	rm -f "$NGINX_BCONF_TEMP" > /dev/null 2>&1
 }
 
 syshealth_adapt_nginx_resolver() {

+ 15 - 0
src/deb/nginx/preinst

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Run triggers only on updates
+if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
+	exit
+fi
+
+# Create a new Backup folder
+HESTIA_BACKUP="/root/hst_nginx_backups/$(date +%d%m%Y%H%M)"
+mkdir -p HESTIA_BACKUP
+
+# Create a backup of the current configuration
+cp -r /usr/local/hestia/nginx/conf/nginx.conf $HESTIA_BACKUP/nginx.conf
+
+exit