-
Notifications
You must be signed in to change notification settings - Fork 7
/
vsftpd-profile.sh
105 lines (75 loc) · 2.79 KB
/
vsftpd-profile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
USAGE="
SYNTAX: $0 [-h] [-u | -d]
DESCRIPTION:
This script is used to specify whether the vsftp server should active anonymous downloads or anonymous uploads
REQUIREMENTS:
1.) The config files must be named vsftpd-anon-downloads.conf and vsftpd-anon-uploads.conf
2.) Debian OS will auto-set the config directory as /etc Fedora is /etc/vsftpd which are the package installer defaults
CONTACT INFORMATION
Company: OsbornePro LLC.
Website: https://osbornepro.com
Author: Robert H. Osborne
Contact: rosborne@osbornepro.com
USAGE: $0 [-u | -d]
OPTIONS:
-h : Displays the help information for the command.
-u : Switch VSFTPD server to use Anonymous Uploads Configuration
-d : Switch VSFTPD server to use Anonymous Downloads Configuration
EXAMPLES:
$0 -u
# On Fedora this example uses the /etc/vsftpd/vsftpd-anon-uploads.conf configuration file with VSFTPD
# On Debian this example uses the /etc/vsftpd-anon-uploads.conf configuration file with VSFTPD
$0 -d
# On Fedora this example uses the /etc/vsftpd/vsftpd-anon-downloads.conf configuration file with VSFTPD
# On Debian this example uses the /etc/vsftpd-anon-downloads.conf configuration file with VSFTPD
"
function allow_ctrlc {
# Allow Ctrl+C to stop execution
trap '
trap - INT # restore default INT handler
kill -s INT "$$"
' INT
} # End function allow_ctrlc
function print_usage {
printf "$USAGE\n" >&2
exit 1
} # End function print_usage
function change_configfile {
cp "${CONFIGFILE}" "${VSFTPDPATH}/vsftpd.conf"
}
function restart_vsftpd_service {
printf "[*] Restarting the VSFTPD service \n"
systemctl restart vsftpd.service
}
OSID=$(grep ID_LIKE /etc/os-release | cut -d"=" -f 2)
if [ "$OSID" == '"debian"' ]; then
printf "[*] Using the Debian based OS settings \n"
VSFTPDPATH="/etc"
elif [ "$OSID" == '"fedora"' ]; then
printf "[*] Using the Fedora based OS settings \n"
VSFTPDPATH="/etc/vsftpd"
else
printf "[!] Operating system ID is not Debian or Fedora \n"
exit 1
fi
while [ ! -z "$1" ]; do
case "$1" in
-u)
shift
CONFIGFILE="${VSFTPDPATH}/vsftpd-anon-uploads.conf"
printf "[*] Using the UPLOADS configuration \n"
;;
-d)
shift
CONFIGFILE="${VSFTPDPATH}/vsftpd-anon-downloads.conf"
printf "[*] Using the DOWNLOADS configuration \n"
;;
*)
print_usage
;;
esac
shift
done
change_configfile
restart_vsftpd_service