Config network on %pre section with menu

Issues related to configuring your network
Post Reply
Posts: 1
Joined: 2017/11/17 20:36:06

Config network on %pre section with menu

Post by mfons » 2017/11/17 20:53:07

Hi all,
I'm confused about this.
Im playing with a kickstart file to install a 7.4 release.

If I type network config on cmdline on the iso like this:
label linux
menu label ^Install custom image [ type network config ]
menu default
kernel vmlinuz
append initrd=initrd.img inst.ks=cdrom:/ks/rhel7.ks hn=xxxx ip= netmask= gateway= ksdevice=ensf0

Later on ks file:
%pre --interpreter /bin/bash --log /tmp/ks-pre.log
echo "Interpreting any command line arguments..."
servername=$(awk -F 'hn=' '{print $2}' /proc/cmdline |cut -d ' ' -f 1)
ip=$(awk -F 'ip=' '{print $2}' /proc/cmdline |cut -d ' ' -f 1)
netmask=$(awk -F 'netmask=' '{print $2}' /proc/cmdline |cut -d ' ' -f 1)
gateway=$(awk -F 'gateway=' '{print $2}' /proc/cmdline |cut -d ' ' -f 1)
device=$(awk -F 'ksdevice=' '{print $2}' /proc/cmdline |cut -d ' ' -f 1)

echo "network --bootproto=static --ip=$ip --netmask=$netmask --gateway=$gateway --device=$device --hostname=$servername --noipv6 " > /tmp/ks-network.cfg

OK, no problem, this works perfect.

But I would like to have a menu, so it asks me about config network like this:

The isolinux section would be:
label linux
menu label ^Install custom image [ with network menu ]
kernel vmlinuz
append initrd=initrd.img inst.ks=cdrom:/ks/rhel7_menu.ks

And later on %pre section:

%pre --interpreter /bin/bash --log /tmp/ks-pre.log

exec < $curTTY > $curTTY 2> $curTTY

while [ x"$answer" != "xy" ] && [ x"$answer" != "xY" ] ; do
echo -n "Enter hostname: "; read hostname
echo -n "Enter ip: "; read ip
echo -n "Enter netmask: "; read netmask
echo -n "Enter default gw: "; read gw
echo -n "Enter network dev: "; read device

echo You entered:
echo -e "\tHostname: $hostname"
echo -e "\tIP: $ip"
echo -e "\tNetmask: $netmask"
echo -e "\tDefault gw: $gw"
echo -e "\tNetwork dev: $device"
echo -n "Is this correct? [y/n] "; read answer

echo "network --bootproto=static --ip=$ip --netmask=$netmask --gateway=$gw --device=$device --hostname=$hostname --noipv6 " > /tmp/ks-network.cfg

This does not work.

I have my url variable pointing to my repo in both ks files:

url --url=""

But it seems this is not available if I do not type network config on cmdline...

The issue is that if I type config network on cmdline of the isolinux boot, it works, but indeed, the network gets configured on %pre section, isnt it?

So, why this dont work in "interactive mode" if I get the network configured on %pre section on both ??

Thanks guys.


Post Reply