How do I set a Static IP after DHCP Kickstart Install?

asked 2015-02-04 12:45:01 -0500

twest gravatar image

updated 2017-01-13 15:25:13 -0500

mattdm gravatar image

I am installing Fedora 20 via a Kickstart script. In order for the machine that the OS is being installed on to reach the server housing the install files, I have to use --bootpronto=dhcp. However, in the pre-script I am asking for the user to define what they want the IP, Netmask, Gateway, and Hostname to be. This information is then saved to /tmp/includes.

After the install finishes the Hostname is pulled from the /tmp/includes file, but the rest of the static network configuration is not. I cannot figure out where I went wrong, so any help would be appreciated.

Here is the relevant part of the script:

# Begin Pre-script
%pre
exec < /dev/tty3 > /dev/tty3
chvt 3
echo -n "Enter Hostname:"
read hostname
echo -n "Enter IP Address:"
read ipaddress
echo -n "Enter Netmask:"
read netmask
echo -n "Enter Gateway:"
read gateway
echo -n "Enter user name (Leave blank for none):"
read username
if [ "$username" != "" ]; then
echo -n "Enter user password:"
read userpass
fi
echo -n "Enter root password:"
read rootpass
echo
echo "----Verify Selections----"
printf "%-15s%s\n" "Hostname:" "$hostname"
printf "%-15s%s\n" "IP Address:" "$ipaddress"
printf "%-15s%s\n" "Netmask:" "$netmask"
printf "%-15s%s\n" "Gateway:" "$gateway"
if [ "$username" != "" ]; then
printf "%-15s%s\n" "Username:" "$username"
printf "%-15s%s\n" "User Pass:" "$userpass"
fi
printf "%-15s%s\n" "Root Pass:" "$rootpass"
echo "---------------------------"
echo
echo -n "Is this correct? (y/n): "
read correct
if [[ $correct == "Y" || $correct == "y" ]]; then
echo "network --bootproto=static --noipv6 --onboot=yes --ip=$ipaddress --netmask=$netmask --gateway=$gateway
--hostname=$hostname --nameserver 209.160.56.50,209.160.56.60" >> /tmp/includes
 # Do not create user if none specified
if [ "$username" != "" ]; then
echo "user --name=$username --groups=wheel --password=$userpass" >> /tmp/includes
fi
echo "rootpw $rootpass" >> /tmp/includes
else
 # Restart script if user exits
echo
echo "Oops!"
sleep 1
echo "Let's try this again ..."
sleep 1
echo
echo
echo
echo
ks_options
fi
%end
 # Parse the include file for kickstart parameters
%include /tmp/includes

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Would it be simpler, to use mac address and let your router set static ip using the dhcp reservation feature of the router? What happens if two different users choose the same IP address? Just a thought.

SteveEbey73701 gravatar imageSteveEbey73701 ( 2017-01-14 20:24:01 -0500 )edit