|
|
@@ -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
|