Skip to content

Commit a6e4cde

Browse files
authored
Backend Port: Multirow and multiport support (hestiacp#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
1 parent b299b35 commit a6e4cde

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

bin/v-add-firewall-chain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ source $HESTIA/func/firewall.sh
3131
source_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|;||")
3535
if [ -z "$hestiaport" ]; then
3636
hestiaport=8083
3737
fi

bin/v-change-sys-port

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# Argument definition
1414
PORT=$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
6062
if [ "$ORIGINAL_PORT" = "$PORT" ]; then
@@ -64,7 +66,7 @@ else
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
@@ -97,6 +99,9 @@ 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
100105
log_event "$OK" "$ARGUMENTS"
101106

102107
exit

func/syshealth.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)