File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ source $HESTIA/func/firewall.sh
3131source_conf " $HESTIA /conf/hestia.conf"
3232
3333# Get hestia port by reading nginx.conf
34- hestiaport=$( grep ' listen' $HESTIA /nginx/conf/nginx.conf | awk ' {print $2}' | sed " s|;||" )
34+ hestiaport=$( grep -m 1 ' listen' $HESTIA /nginx/conf/nginx.conf | awk ' {print $2}' | sed " s|;||" )
3535if [ -z " $hestiaport " ]; then
3636 hestiaport=8083
3737fi
Original file line number Diff line number Diff line change 1212
1313# Argument definition
1414PORT=$1
15+ NGINX_CONFIG=" $HESTIA /nginx/conf/nginx.conf"
1516
1617# Includes
1718# shellcheck source=/etc/hestiacp/hestia.conf
@@ -54,7 +55,8 @@ check_hestia_demo_mode
5455# ----------------------------------------------------------#
5556
5657# Get original port
57- ORIGINAL_PORT=$( cat $HESTIA /nginx/conf/nginx.conf | grep " listen" | sed ' s/[^0-9]*//g' )
58+ LISTEN_ROWS=$( cat ${NGINX_CONFIG} | grep -c " listen" )
59+ ORIGINAL_PORT=$( cat ${NGINX_CONFIG} | grep -m 1 " listen" | sed ' s/[^0-9]*//g' )
5860
5961# Check if port is different to nginx.conf
6062if [ " $ORIGINAL_PORT " = " $PORT " ]; then
6466 # Set new port in config via v-change-sys-config-value
6567 $BIN /v-change-sys-config-value " BACKEND_PORT" " $PORT "
6668 # Replace port in config files.
67- sed -i " /listen/c\ listen $PORT ssl; " $HESTIA /nginx/conf/nginx.conf
69+ sed -i " s/\( listen[ \t]*.*[: \t]\)[0-9][0-9]*\([^0-9]* ssl\;$\)/\1 $PORT \2/ " ${NGINX_CONFIG}
6870 if [ -d /etc/roundcube/ ]; then
6971 sed -i " /password_hestia_port/c\$ rcmail_config['password_hestia_port'] = '$PORT ';" /etc/roundcube/plugins/password/config.inc.php
7072 fi
9799
98100# Logging
99101$BIN /v-log-action " system" " Warning" " System" " Hestia Control Panel backend port changed (New Value: $PORT , Old Value: $ORIGINAL_PORT )."
102+ if [ $LISTEN_ROWS -gt 1 ]; then
103+ $BIN /v-log-action " system" " Warning" " System" " Hestia Control Panel backend port: Use first of $LISTEN_ROWS listened ports in ${NGINX_CONFIG} "
104+ fi
100105log_event " $OK " " $ARGUMENTS "
101106
102107exit
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ function syshealth_repair_system_config() {
285285
286286 # Backend port
287287 if [[ -z $( check_key_exists ' BACKEND_PORT' ) ]]; then
288- ORIGINAL_PORT=$( cat $HESTIA /nginx/conf/nginx.conf | grep " listen" | sed ' s/[^0-9]*//g' )
288+ ORIGINAL_PORT=$( cat $HESTIA /nginx/conf/nginx.conf | grep -m 1 " listen" | sed ' s/[^0-9]*//g' )
289289 echo " [ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT ')"
290290 $BIN /v-change-sys-config-value ' BACKEND_PORT' $ORIGINAL_PORT
291291 fi
You can’t perform that action at this time.
0 commit comments