From 767e2d9021fa039051bfd8184dd07e33325a4d0f Mon Sep 17 00:00:00 2001 From: dpeca Date: Sat, 24 Aug 2019 03:33:24 +0200 Subject: [PATCH] Create v-change-vesta-port If you accept this PR, please chmod +x this script --- bin/v-change-vesta-port | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 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..1d96023c6 --- /dev/null +++ b/bin/v-change-vesta-port @@ -0,0 +1,62 @@ +#!/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 + +if [ ! -f "$VESTA/conf/port.conf" ]; then + oldport=8083 +else + oldport=`cat $VESTA/conf/port.conf` +fi + +# Includes +source $VESTA/func/main.sh + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +whoami=$(whoami) +if [ "$whoami" != "root" ] && [ "$whoami" != "admin" ] ; then + echo "You must be root or admin to execute this script"; + exit 1; +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 +systemctl restart vesta + +echo "$port" > $VESTA/conf/port.conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$ARGUMENTS" + +exit 0;