diff --git a/bin/v-change-sys-ip-nat b/bin/v-change-sys-ip-nat index 813b90e2..3529dfb8 100755 --- a/bin/v-change-sys-ip-nat +++ b/bin/v-change-sys-ip-nat @@ -1,6 +1,6 @@ #!/bin/bash # info: change ip nat address -# options: IP NAT_IP +# options: IP NAT_IP [RESTART] # # The function for changing nat ip associated with ip. @@ -12,6 +12,7 @@ # Argument defenition ip=$1 nat_ip=$2 +restart=$3 # Includes source $VESTA/conf/vesta.conf @@ -23,7 +24,7 @@ source $VESTA/func/ip.sh # Verifications # #----------------------------------------------------------# -check_args '2' "$#" 'IP NAT_IP' +check_args '2' "$#" 'IP NAT_IP [RESTART]' validate_format 'ip' if [ ! -z "$nat_ip" ]; then validate_format 'nat_ip' @@ -42,11 +43,32 @@ else update_ip_value '$NAT' "$nat_ip" fi +# Change vsftpd config +if [ "$FTP_SYSTEM" = 'vsftpd' ]; then + conf="/etc/vsftpd/vsftpd.conf" + if [ -z "$(grep pasv_address $conf)" ]; then + if [ ! -z "$nat_ip" ]; then + echo "pasv_address=$nat_ip" >> $conf + fi + else + if [ ! -z "$nat_ip" ]; then + sed -i "s/pasv_address=.*/pasv_address='$nat_ip'/g" $conf + else + sed -i "/pasv_address/d" $conf + fi + fi +fi + #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# +# Restart ftp server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-ftp "$EVENT" +fi + # Logging log_history "changed associated nat address on $ip to $nat_ip" '' 'admin' log_event "$OK" "$EVENT" diff --git a/bin/v-restart-ftp b/bin/v-restart-ftp new file mode 100755 index 00000000..55d7c1f2 --- /dev/null +++ b/bin/v-restart-ftp @@ -0,0 +1,48 @@ +#!/bin/bash +# info: restart ftp service +# options: NONE +# +# The function tells ftp server to reread its configuration. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Vsftpd +if [ "$FTP_SYSTEM" = 'vsftpd' ]; then + /etc/init.d/vsftpd reload >/dev/null 2>&1 + if [ $? -ne 0 ]; then + /etc/init.d/vsftpd restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + +# ProFTPD +if [ "$FTP_SYSTEM" = 'proftpd' ]; then + /etc/init.d/proftpd reload >/dev/null 2>&1 + if [ $? -ne 0 ]; then + /etc/init.d/proftpd restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit