mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
pasv_address triggers for vsftpd
This commit is contained in:
parent
c2ccccf142
commit
fa45276267
2 changed files with 72 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: change ip nat address
|
# info: change ip nat address
|
||||||
# options: IP NAT_IP
|
# options: IP NAT_IP [RESTART]
|
||||||
#
|
#
|
||||||
# The function for changing nat ip associated with ip.
|
# The function for changing nat ip associated with ip.
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
ip=$1
|
ip=$1
|
||||||
nat_ip=$2
|
nat_ip=$2
|
||||||
|
restart=$3
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
@ -23,7 +24,7 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '2' "$#" 'IP NAT_IP'
|
check_args '2' "$#" 'IP NAT_IP [RESTART]'
|
||||||
validate_format 'ip'
|
validate_format 'ip'
|
||||||
if [ ! -z "$nat_ip" ]; then
|
if [ ! -z "$nat_ip" ]; then
|
||||||
validate_format 'nat_ip'
|
validate_format 'nat_ip'
|
||||||
|
@ -42,11 +43,32 @@ else
|
||||||
update_ip_value '$NAT' "$nat_ip"
|
update_ip_value '$NAT' "$nat_ip"
|
||||||
fi
|
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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Restart ftp server
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
|
$BIN/v-restart-ftp "$EVENT"
|
||||||
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "changed associated nat address on $ip to $nat_ip" '' 'admin'
|
log_history "changed associated nat address on $ip to $nat_ip" '' 'admin'
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
48
bin/v-restart-ftp
Executable file
48
bin/v-restart-ftp
Executable file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue