[CentOS] kickstart %pre help on C5.4

Tue Jan 12 19:25:02 UTC 2010
nate <centos at linuxpowered.net>

Alan McKay wrote:

> What am I missing here?

Is /bin/bash even available during %pre ?

I just started testing CentOS 5.4 yesterday w/kickstart, currently
all of my systems are 5.2. Tested this under ESX 4.0 this morning.

This is what my %pre looks like now, I consolidated all configs
into a single script that is called

# Note: there doesn't seem to be any way to log stuff that occurs in %pre as
# it occurs outside of the chroot before kickstart loads.
%pre
export KICKSTART_IP=`cat /proc/cmdline | sed s'/.*http:\/\///'g | sed
s'/\/config.*//'g`
wget
http://${KICKSTART_IP}/kickstart-postinstall/bin/kickstart-pre-install-generic.sh
-O /tmp/kickstart-pre-install-generic.sh
chmod 755 /tmp/kickstart-pre-install-generic.sh
/tmp/kickstart-pre-install-generic.sh

then the kickstart-pre-install-generic.sh script contains

#!/bin/sh

export KICKSTART_IP=`cat /proc/cmdline | sed s'/.*http:\/\///'g | sed
s'/\/config.*//'g`
export KERNEL_VERSION=`uname -r`

# No /etc/redhat-release during pre, so guessing based on kernel version
echo $KERNEL_VERSION | grep "2.6.9" && export CURRENT_OS="RHEL4"
echo $KERNEL_VERSION | grep "2.6.9" || export CURRENT_OS="RHEL5"

###############################################################################
## Attempt to auto detect console device                                     ##
###############################################################################

grep -q "ttyS0,9600" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS0_9600.cfg
-O /tmp/console.config
grep -q "ttyS0,57600" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS0_57600.cfg
-O /tmp/console.config
grep -q "ttyS0,115200" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS0_115200.cfg
-O /tmp/console.config

grep -q "ttyS1,9600" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS1_9600.cfg
-O /tmp/console.config
grep -q "ttyS1,57600" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS1_57600.cfg
-O /tmp/console.config
grep -q "ttyS1,115200" /proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/console_ttyS1_115200.cfg
-O /tmp/console.config

# Default to VGA if we can't find a serial console defined
[ ! -f "/tmp/console.config" ] && wget
http://${KICKSTART_IP}/config/common/rhel_5/console/vga.cfg -O
/tmp/console.config

###############################################################################
## Attempt to auto detect network device                                     ##
###############################################################################

[ "$CURRENT_OS" == "RHEL5" ] && grep -q "ksdevice=eth0" /proc/cmdline &&
wget
http://${KICKSTART_IP}/config/common/rhel_5/network/ksdevice_eth0.config -O
/tmp/network.config
[ "$CURRENT_OS" == "RHEL5" ] && grep -q "ksdevice=eth1" /proc/cmdline &&
wget
http://${KICKSTART_IP}/config/common/rhel_5/network/ksdevice_eth1.config -O
/tmp/network.config

echo $KERNEL_VERSION | grep "2.6.9" && grep -q "ksdevice=eth0" /proc/cmdline
&& wget
http://${KICKSTART_IP}/config/common/rhel_4/network/ksdevice_eth0.config -O
/tmp/network.config
echo $KERNEL_VERSION | grep "2.6.9" &&  grep -q "ksdevice=eth1"
/proc/cmdline && wget
http://${KICKSTART_IP}/config/common/rhel_4/network/ksdevice_eth1.config -O
/tmp/network.config


# Default to eth0 if we don't see anything specified
[ "$CURRENT_OS" == "RHEL5" ] &&  [ ! -f "/tmp/network.config" ] && wget
http://${KICKSTART_IP}/config/common/rhel_5/network/ksdevice_eth0.config -O
/tmp/network.config
echo $KERNEL_VERSION | grep "2.6.9" && [ ! -f "/tmp/network.config" ] &&
wget
http://${KICKSTART_IP}/config/common/rhel_4/network/ksdevice_eth0.config -O
/tmp/network.config

###############################################################################
## Attempt to auto detect custom swap size                                   ##
###############################################################################
grep -qi "swapsize" /proc/cmdline && export SWAPSIZE=`cat /proc/cmdline |
sed s'/ /\n/'g | grep swapsize | sed s'/swapsize=//'g`
[ -z "$SWAPSIZE" ] && export SWAPSIZE="4096"
echo "part swap --size=${SWAPSIZE}" >/tmp/swap.config

-- end script --

nate