mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-22 14:24:07 -07:00
Create v-change-vesta-port
If you accept this PR, please chmod +x this script
This commit is contained in:
parent
e82ad200b7
commit
767e2d9021
1 changed files with 62 additions and 0 deletions
62
bin/v-change-vesta-port
Normal file
62
bin/v-change-vesta-port
Normal file
|
@ -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;
|
Loading…
Add table
Add a link
Reference in a new issue