File tree Expand file tree Collapse file tree 2 files changed +72
-2
lines changed
Expand file tree Collapse file tree 2 files changed +72
-2
lines changed Original file line number Diff line number Diff line change 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
1212# Argument defenition
1313ip=$1
1414nat_ip=$2
15+ restart=$3
1516
1617# Includes
1718source $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] '
2728validate_format ' ip'
2829if [ ! -z " $nat_ip " ]; then
2930 validate_format ' nat_ip'
4243 update_ip_value ' $NAT' " $nat_ip "
4344fi
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
5173log_history " changed associated nat address on $ip to $nat_ip " ' ' ' admin'
5274log_event " $OK " " $EVENT "
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments