RHEL5/CentOS5 KS Network Oddities (ifcfg-* gets re-written)

Shabazian, Chip Chip.Shabazian at bankofamerica.com
Thu Sep 27 15:20:22 UTC 2007


I don't see why you can't ask your network questions in %pre.  You say
you can't (and say "see below"), but I don't see anything below (or
above) that prevents you from doing it this way.

-----Original Message-----
From: kickstart-list-bounces at redhat.com
[mailto:kickstart-list-bounces at redhat.com] On Behalf Of kslist
Sent: Thursday, September 27, 2007 6:00 AM
To: Discussion list about Kickstart
Subject: Re: RHEL5/CentOS5 KS Network Oddities (ifcfg-* gets re-written)


Hi Everyone,

here's how I fixed it:

This is way at the end of my %post:

#
# Finish local network setup
#
cat <<EOF > /mnt/sysimage/root/net.conf.sh
#!/bin/sh
echo -e " ** Completing network setup..."
mv /etc/sysconfig/network.new /etc/sysconfig/network
mv /etc/sysconfig/network-scripts/ifcfg-eth0.new \
/etc/sysconfig/network-scripts/ifcfg-eth0
if [ -f /etc/sysconfig/network-scripts/ifcfg-eth1.new ] ; then
  mv /etc/sysconfig/network-scripts/ifcfg-eth1.new \
/etc/sysconfig/network-scripts/ifcfg-eth1
fi
mv /etc/hosts.new /etc/hosts
mv /etc/resolv.conf.new /etc/resolv.conf
service network restart
hostname $HN
sed -e 's/^\/root\/net\.conf\.sh//' /etc/rc.local > /tmp/rc.local
mv /tmp/rc.local /etc/rc.local
rm -f /root/net.conf.sh
EOF
chmod 755 /mnt/sysimage/root/net.conf.sh

#
# Set the rc.local to move the new network config into place
#
cat <<EOF >> /mnt/sysimage/etc/rc.local
/root/net.conf.sh
EOF


Now, why do I do something that horrible? The reason is this: my
kickstart
is interactive. My kickstart asks the installer various questions, such
as
hostname, IP, etc., and it sets the config files apropriately (ie, it
wrotes directly into /etc/sysconfig/network-scripts/ifcfg-eth0, etc.)

So to answer the questions:
- I can't config in %pre, because of the infelxibility of the "network"
directive (see below)
- I used the option "firstboot --disable" to turn off firstboot, yet the
network configuration files still get mangled somehow.
- I want to use DHCP _for the installation_ only, I do not want to use
DHCP _for the installed system_.
- I actually don't mind first-boot running, because it does other useful
things, however:
- Firstboot SHOULD NOT be connected to the kickstart "network"
directive!
They should not be coupled at all. OR, there has got to be an option for
"network" and "firstboot" that allows me to use DHCP for the install
process and still use fixed IPs for the installed system

As you can see from my work-around, I use /etc/rc.local to overwrite the
files that first-boot mangles, and since its a one-time event, I also
use
rc.local to remove the from itself so that the re-write script is never
called after that first time, and the shell script that does the
re-writing itself is also erased.

This is really a terrible thing, to have to do that, and a result from
kick-start 'doing a little too much thinking" for me, if I may
respectfully put it that way. ;)

If there is a better solution, I'm all ears! =)

Thanks,

-Christian

On Wed, September 26, 2007 19:27, John Wang wrote:
> Hello Christian
>
> How about putting the following into your %post:
>
>     echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot
>
> That should fool firstboot into thinking that it already ran...
>
> Regards,
> John
>
>
> On 9/25/07 6:02 PM, "kslist" <kslist at devo.com> wrote:
>
>> Hello KSers,
>>
>> I am using my Kickstart script that I have adapted from RHEL 2.1, 3,
and
>> 4
>> now on CentOS 5. CentOS 5 behaves differently when it comes to
network
>> configuration.
>>
>> In essence: AFTER the successfull installation, during the first
startup
>> of the OS, something desctroys my network configuration.
Specifically,
>> the
>> files that I have directly written in my %post script:
>> /etc/sysconfig/network
>> /etc/sysconfig/network-scripts/ifcfg-eth0
>> /etc/sysconfig/network-scripts/ifcfg-eth1
>> /etc/hosts
>> /etc/resolve.conf
>> are modified, and in the case of the ifcfg-* scripts, my scripts are
>> moved
>> to a *.bak file (which have a datestamp later than the files I
created
>> via
>> %post, and which correspond to the firstboot) and a completely
newfile
>> is
>> created in its place.
>>
>> The network configuration that replaces my own is one for DHCP.
>>
>> My guess is that this is a result of a change in behaviour of the
>> "network" option. To quote from the RHEL 5 Installation Guide:
>>
>> "Configures network information for the system. If the kickstart
>> installation does not require networking (in other words, it is not
>> installed over NFS, HTTP, or FTP), networking is not configured for
the
>> system. If the installation does require networking and network
>> information is not provided in the kickstart file, the installation
>> program assumes that the installation should be done over eth0 via a
>> dynamic IP address (BOOTP/DHCP), and configures the final, installed
>> system to determine its IP address dynamically. The network option
>> configures networking information for kickstart installations via a
>> network as well as for the installed system."
>>
>> Now, I see a problem here:
>> - I use DHCP to install the system (via Kickstart)
>> - I however do NOT want to run the subsequently installed OS to use
>> DHCP.
>>
>> I would say that is a very very normal thing to want.
>>
>> However, the way the manual describes it, and from the behaviour I
have
>> seen, it is not possible to install via DHCP, and then setup your own
>> network configuration in %post, because your configuration will be
>> overwritten next time you boot the system.
>>
>> Ussing "firstboot --disable" doesn't help.
>>
>> Please help!
>>
>> -Christian
>>
>> _______________________________________________
>> Kickstart-list mailing list
>> Kickstart-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/kickstart-list
>
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list
>

_______________________________________________
Kickstart-list mailing list
Kickstart-list at redhat.com
https://www.redhat.com/mailman/listinfo/kickstart-list




More information about the Kickstart-list mailing list