Skip to content

Commit fa45276

Browse files
committed
pasv_address triggers for vsftpd
1 parent c2ccccf commit fa45276

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

bin/v-change-sys-ip-nat

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: change ip nat address
3-
# options: IP NAT_IP
3+
# options: IP NAT_IP [RESTART]
44
#
55
# The function for changing nat ip associated with ip.
66

@@ -12,6 +12,7 @@
1212
# Argument defenition
1313
ip=$1
1414
nat_ip=$2
15+
restart=$3
1516

1617
# Includes
1718
source $VESTA/conf/vesta.conf
@@ -23,7 +24,7 @@ source $VESTA/func/ip.sh
2324
# Verifications #
2425
#----------------------------------------------------------#
2526

26-
check_args '2' "$#" 'IP NAT_IP'
27+
check_args '2' "$#" 'IP NAT_IP [RESTART]'
2728
validate_format 'ip'
2829
if [ ! -z "$nat_ip" ]; then
2930
validate_format 'nat_ip'
@@ -42,11 +43,32 @@ else
4243
update_ip_value '$NAT' "$nat_ip"
4344
fi
4445

46+
# Change vsftpd config
47+
if [ "$FTP_SYSTEM" = 'vsftpd' ]; then
48+
conf="/etc/vsftpd/vsftpd.conf"
49+
if [ -z "$(grep pasv_address $conf)" ]; then
50+
if [ ! -z "$nat_ip" ]; then
51+
echo "pasv_address=$nat_ip" >> $conf
52+
fi
53+
else
54+
if [ ! -z "$nat_ip" ]; then
55+
sed -i "s/pasv_address=.*/pasv_address='$nat_ip'/g" $conf
56+
else
57+
sed -i "/pasv_address/d" $conf
58+
fi
59+
fi
60+
fi
61+
4562

4663
#----------------------------------------------------------#
4764
# Vesta #
4865
#----------------------------------------------------------#
4966

67+
# Restart ftp server
68+
if [ "$restart" != 'no' ]; then
69+
$BIN/v-restart-ftp "$EVENT"
70+
fi
71+
5072
# Logging
5173
log_history "changed associated nat address on $ip to $nat_ip" '' 'admin'
5274
log_event "$OK" "$EVENT"

bin/v-restart-ftp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# info: restart ftp service
3+
# options: NONE
4+
#
5+
# The function tells ftp server to reread its configuration.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Includes
13+
source $VESTA/conf/vesta.conf
14+
source $VESTA/func/main.sh
15+
16+
17+
#----------------------------------------------------------#
18+
# Action #
19+
#----------------------------------------------------------#
20+
21+
# Vsftpd
22+
if [ "$FTP_SYSTEM" = 'vsftpd' ]; then
23+
/etc/init.d/vsftpd reload >/dev/null 2>&1
24+
if [ $? -ne 0 ]; then
25+
/etc/init.d/vsftpd restart >/dev/null 2>&1
26+
if [ $? -ne 0 ]; then
27+
exit $E_RESTART
28+
fi
29+
fi
30+
fi
31+
32+
# ProFTPD
33+
if [ "$FTP_SYSTEM" = 'proftpd' ]; then
34+
/etc/init.d/proftpd reload >/dev/null 2>&1
35+
if [ $? -ne 0 ]; then
36+
/etc/init.d/proftpd restart >/dev/null 2>&1
37+
if [ $? -ne 0 ]; then
38+
exit $E_RESTART
39+
fi
40+
fi
41+
fi
42+
43+
44+
#----------------------------------------------------------#
45+
# Vesta #
46+
#----------------------------------------------------------#
47+
48+
exit

0 commit comments

Comments
 (0)