|
|
@@ -18,7 +18,7 @@ NGINX_CONFIG="$HESTIA/nginx/conf/nginx.conf"
|
|
|
# shellcheck source=/etc/hestiacp/hestia.conf
|
|
|
source /etc/hestiacp/hestia.conf
|
|
|
# shellcheck source=/usr/local/hestia/func/main.sh
|
|
|
-source $HESTIA/func/main.sh
|
|
|
+source "$HESTIA/func/main.sh"
|
|
|
# load config file
|
|
|
source_conf "$HESTIA/conf/hestia.conf"
|
|
|
|
|
|
@@ -55,8 +55,8 @@ check_hestia_demo_mode
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
# Get original port
|
|
|
-LISTEN_ROWS=$(cat ${NGINX_CONFIG} | grep -c "listen")
|
|
|
-ORIGINAL_PORT=$(cat ${NGINX_CONFIG} | grep -m1 "listen" | sed 's/[^0-9]*//g')
|
|
|
+LISTEN_ROWS=$(cat "$NGINX_CONFIG" | grep -c "listen")
|
|
|
+ORIGINAL_PORT=$(sed -ne "/listen/{s/.*listen[^0-9]*\([0-9][0-9]*\)[ \t]*ssl\;/\1/p;q}" "$NGINX_CONFIG")
|
|
|
|
|
|
# Check if port is different to nginx.conf
|
|
|
if [ "$ORIGINAL_PORT" = "$PORT" ]; then
|
|
|
@@ -64,9 +64,9 @@ if [ "$ORIGINAL_PORT" = "$PORT" ]; then
|
|
|
exit
|
|
|
else
|
|
|
# Set new port in config via v-change-sys-config-value
|
|
|
- $BIN/v-change-sys-config-value "BACKEND_PORT" "$PORT"
|
|
|
+ "$BIN/v-change-sys-config-value" "BACKEND_PORT" "$PORT"
|
|
|
# Replace port in config files.
|
|
|
- sed -i "s/\(listen[ \t]*.*[: \t]\)[0-9][0-9]*\([^0-9]*ssl\;$\)/\1$PORT\2/" ${NGINX_CONFIG}
|
|
|
+ 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
|
|
|
@@ -75,21 +75,21 @@ else
|
|
|
fi
|
|
|
|
|
|
if [ -f "$HESTIA/data/firewall/rules.conf" ]; then
|
|
|
- sed -i "/COMMENT='HESTIA'/c\RULE='2' ACTION='ACCEPT' PROTOCOL='TCP' PORT='$PORT' IP='0.0.0.0/0' COMMENT='HESTIA' SUSPENDED='no' TIME='07:40:16' DATE='2014-05-25'" $HESTIA/data/firewall/rules.conf
|
|
|
+ sed -i "/COMMENT='HESTIA'/c\RULE='2' ACTION='ACCEPT' PROTOCOL='TCP' PORT='$PORT' IP='0.0.0.0/0' COMMENT='HESTIA' SUSPENDED='no' TIME='07:40:16' DATE='2014-05-25'" "$HESTIA/data/firewall/rules.conf"
|
|
|
fi
|
|
|
|
|
|
- if [ -f $HESTIA/data/firewall/chains.conf ]; then
|
|
|
- sed -i "/CHAIN='HESTIA'/c\CHAIN='HESTIA' PORT='$PORT' PROTOCOL='TCP'" $HESTIA/data/firewall/chains.conf
|
|
|
+ if [ -f "$HESTIA/data/firewall/chains.conf" ]; then
|
|
|
+ sed -i "/CHAIN='HESTIA'/c\CHAIN='HESTIA' PORT='$PORT' PROTOCOL='TCP'" "$HESTIA/data/firewall/chains.conf"
|
|
|
fi
|
|
|
|
|
|
# Restart services
|
|
|
if [ -n "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != no ]; then
|
|
|
- $BIN/v-restart-service iptables
|
|
|
+ "$BIN/v-restart-service" iptables
|
|
|
fi
|
|
|
|
|
|
# Check if Hestia is running
|
|
|
if [[ $(ps -eaf | grep -i hestia | sed '/^$/d' | wc -l) -gt 1 ]]; then
|
|
|
- $BIN/v-restart-service hestia
|
|
|
+ "$BIN/v-restart-service" hestia
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
@@ -98,9 +98,9 @@ fi
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
# Logging
|
|
|
-$BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port changed (New Value: $PORT, Old Value: $ORIGINAL_PORT)."
|
|
|
+"$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}"
|
|
|
+ "$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"
|
|
|
|