Просмотр исходного кода

Backend Port: Multirow and multiport support (#3272)

* Backend Port: Multirow and multiport support

Preparation for IPV6 support

* Backend Port: Alignment to main version on GitHub

* Backend Port: 'grub -m 1' for two additional scripts
asmcc 3 лет назад
Родитель
Сommit
a6e4cde719
3 измененных файлов с 9 добавлено и 4 удалено
  1. 1 1
      bin/v-add-firewall-chain
  2. 7 2
      bin/v-change-sys-port
  3. 1 1
      func/syshealth.sh

+ 1 - 1
bin/v-add-firewall-chain

@@ -31,7 +31,7 @@ source $HESTIA/func/firewall.sh
 source_conf "$HESTIA/conf/hestia.conf"
 
 # Get hestia port by reading nginx.conf
-hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
+hestiaport=$(grep -m 1 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
 if [ -z "$hestiaport" ]; then
 	hestiaport=8083
 fi

+ 7 - 2
bin/v-change-sys-port

@@ -12,6 +12,7 @@
 
 # Argument definition
 PORT=$1
+NGINX_CONFIG="$HESTIA/nginx/conf/nginx.conf"									
 
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
@@ -54,7 +55,8 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Get original port
-ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
+LISTEN_ROWS=$(cat ${NGINX_CONFIG} | grep -c "listen")
+ORIGINAL_PORT=$(cat ${NGINX_CONFIG} | grep -m 1 "listen" | sed 's/[^0-9]*//g')
 
 # Check if port is different to nginx.conf
 if [ "$ORIGINAL_PORT" = "$PORT" ]; then
@@ -64,7 +66,7 @@ else
 	# Set new port in config via v-change-sys-config-value
 	$BIN/v-change-sys-config-value "BACKEND_PORT" "$PORT"
 	# Replace port in config files.
-	sed -i "/listen/c\        listen          $PORT ssl;" $HESTIA/nginx/conf/nginx.conf
+	sed -i "s/\(listen[ \t]*.*[: \t]\)[0-9][0-9]*\([^0-9]*ssl\;$\)/\1$PORT\2/" ${NGINX_CONFIG}
 	if [ -d /etc/roundcube/ ]; then
 		sed -i "/password_hestia_port/c\$rcmail_config['password_hestia_port'] = '$PORT';" /etc/roundcube/plugins/password/config.inc.php
 	fi
@@ -97,6 +99,9 @@ fi
 
 # Logging
 $BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port changed (New Value: $PORT, Old Value: $ORIGINAL_PORT)."
+if [ $LISTEN_ROWS -gt 1 ]; then
+	$BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port: Use first of $LISTEN_ROWS listened ports in ${NGINX_CONFIG}"
+fi
 log_event "$OK" "$ARGUMENTS"
 
 exit

+ 1 - 1
func/syshealth.sh

@@ -285,7 +285,7 @@ function syshealth_repair_system_config() {
 
 	# Backend port
 	if [[ -z $(check_key_exists 'BACKEND_PORT') ]]; then
-		ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
+		ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep -m 1 "listen" | sed 's/[^0-9]*//g')
 		echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT')"
 		$BIN/v-change-sys-config-value 'BACKEND_PORT' $ORIGINAL_PORT
 	fi