Skip to content

Instantly share code, notes, and snippets.

@WillNilges
Last active July 29, 2020 04:54
Show Gist options
  • Save WillNilges/4e8c4fc93b93ef68fbd0f8a0e30be605 to your computer and use it in GitHub Desktop.
Save WillNilges/4e8c4fc93b93ef68fbd0f8a0e30be605 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
if ! [ $(id -g) == 0 ];then
echo 'Please run as root.'
exit 1
fi
dnf install tftp-server tftp -y
cp /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service
cp /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socket
echo '
[Unit]
Description=Tftp Server
Requires=tftp-server.socket
Documentation=man:in.tftpd
[Service]
ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot
StandardInput=socket
[Install]
WantedBy=multi-user.target
Also=tftp-server.socket
' > /etc/systemd/system/tftp-server.service
systemctl daemon-reload
systemctl enable --now tftp-server
chmod 777 /var/lib/tftpboot
firewall-cmd --add-service=tftp --perm
firewall-cmd --reload
echo 'Server is installed, up, and running. Check /var/lib/tftpboot.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment