From 76072b73981e1097a75e215deed9b9d37d5894c1 Mon Sep 17 00:00:00 2001 From: Anton Reutov Date: Thu, 29 Jul 2021 20:29:51 +0300 Subject: [PATCH] Change default vesta port --- bin/v-change-vesta-port | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 bin/v-change-vesta-port diff --git a/bin/v-change-vesta-port b/bin/v-change-vesta-port new file mode 100644 index 000000000..3f3866549 --- /dev/null +++ b/bin/v-change-vesta-port @@ -0,0 +1,60 @@ +#!/bin/bash +# info: change vesta port +# options: port +# +# Function will change vesta port + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument definition +port=$1 + +if [ -z "$VESTA" ]; then + VESTA="/usr/local/vesta" +fi + +# Get current vesta port by reading nginx.conf +oldport=$(grep 'listen' $VESTA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||") +if [ -z "$oldport" ]; then + oldport=8083 +fi + +# Includes +source $VESTA/func/main.sh + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking permissions +if [ "$(id -u)" != '0' ]; then + check_result $E_FORBIDEN "You must be root to execute this script" +fi + +check_args '1' "$#" 'PORT' +is_int_format_valid "$port" 'port number' + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +sed -i "s|$oldport;|$port;|g" $VESTA/nginx/conf/nginx.conf +if [ -f "/etc/roundcube/plugins/password/config.inc.php" ]; then + sed -i "s|'$oldport'|'$port'|g" /etc/roundcube/plugins/password/config.inc.php +fi +sed -i "s|'$oldport'|'$port'|g" $VESTA/data/firewall/rules.conf +$VESTA/bin/v-update-firewall +systemctl restart fail2ban.service +sed -i "s| $oldport | $port |g" /etc/iptables.rules +systemctl restart vesta + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$ARGUMENTS" + +exit 0;