Created
November 18, 2024 14:22
-
-
Save cabb/d7740ef96da3996a4d6646f155d8637b to your computer and use it in GitHub Desktop.
TFTP install el9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables | |
RPM_FILE="tftp-server-5.2-38.el9.x86_64.rpm" | |
TFTP_HOMEDIR="/home/tftp-home" | |
if [ ! -f "$RPM_FILE" ]; then | |
echo "Error: $RPM_FILE not found. Please download the RPM first." | |
exit 1 | |
fi | |
echo "Installing tftp-server..." | |
sudo dnf install -y "$RPM_FILE" | |
SERVICE_FILE="/usr/lib/systemd/system/tftp.service" | |
echo "Configuring TFTP service..." | |
if [ -f "$SERVICE_FILE" ]; then | |
sed -i.bak \ | |
-e "s|ExecStart=.*|ExecStart=/usr/sbin/in.tftpd --secure $TFTP_HOMEDIR|" \ | |
"$SERVICE_FILE" | |
else | |
echo "TFTP service file not found at $SERVICE_FILE. Exiting." | |
exit 1 | |
fi | |
echo "Reloading systemd configuration..." | |
systemctl daemon-reload | |
echo "Configuring firewall to allow TFTP service..." | |
sudo firewall-cmd --add-service=tftp --permanent | |
sudo firewall-cmd --reload | |
echo "Enabling and starting tftp-server..." | |
sudo systemctl enable tftp | |
sudo systemctl start tftp | |
echo "Verifying TFTP service status..." | |
systemctl status tftp --no-pager | |
echo "TFTP setup completed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment