-
Notifications
You must be signed in to change notification settings - Fork 5
/
tftp-setup.sh
executable file
·51 lines (40 loc) · 1.1 KB
/
tftp-setup.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
#!/bin/bash
# This script is designed to set up a TFTP server, which anyone can access
# Check if user is root
if [ $UID != 0 ] ; then
echo "Not root!"
exit 1
fi
# Check if OS has APT-GET
if [ -f "/etc/apt/sources.list" ] ; then
CANRUN="Y"
fi
if [ $CANRUN == "Y" ] ; then
# First let's update the system, and install the xinetd, tftpd and tftp
apt-get update && apt-get upgrade -y && apt-get install xinetd tftpd tftp -y
# Next let's insert our xinetd configuration for tftp
cat >/etc/xinetd.d/tftp <<EOF
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
}
EOF
# Create a folder /tftpboot and set proper ownership with permissions so that the nobody group has access.
# The files inside don't need special permissions.
mkdir /tftpboot
chmod -R 777 /tftpboot
chown -R nobody /tftpboot
service xinetd restart
if ! service xinetd restart ; then
/etc/init.d/xinetd restart
fi
echo "Done!"
echo "Please reboot to make sure everything comes up properly."
fi