Hey folks! I'm doing some %pre work for the first time in a very long time, and have been at this all day so far and still don't have anything sorted out properly. First I tried just doing some simple bash stuff like this %pre #!/bin/bash # stuff I reduced "stuff" down to basically a simple "select" statement to echo and read input, just for the sake of debugging. My first problem is that when running the kickstart, the little box would come up saying it is running the pre scripts, but my scripts would never actually run. No output, no prompts, nothing. So after some muddling I tried this : %pre #!/bin/bash exec 1>&3 exec > /dev/tty chvt 3 exec < /dev/tty3 > /dev/tty3 clear # stuff I cannot say I really understand this - it is just something I came across. in any case, now my script seems to run fine, but after it finishes it does not appear to go back to my install. I get messages like : date INFO all kickstart %%pre script(s) have been run date WARNING resolution and depth not specified, try to be sane and that is it - it stops there. I've also tried just : %pre #!/bin/bash chvt 3 clear # stuff With the same results as above. This is all running within VMWare ESXi 4.0 if that matters. What am I missing here? thanks, -Alan -- ?Don't eat anything you've ever seen advertised on TV? - Michael Pollan, author of "In Defense of Food"
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
From: Alan McKay <alan.mckay at gmail.com>> I'm doing some %pre work for the first time in a very long time, and > have been at this all day so far and still don't have anything sorted > out properly. > First I tried just doing some simple bash stuff like this > %pre > #!/bin/bash > # stuff > I reduced "stuff" down to basically a simple "select" statement to > echo and read input, just for the sake of debugging. > My first problem is that when running the kickstart, the little box > would come up saying it is running the pre scripts, but my scripts > would never actually run. No output, no prompts, nothing.For my usb key, I use by example: %pre --interpreter /usr/bin/bash mkdir /usbkey mount /dev/sda2 /usbkey cp -a /usbkey/misc /tmp/ umount /usbkey chvt 3 /tmp/misc/ks_pre.sh | tee /tmp/ks_pre.log 2>&1 chvt 1