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
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://$%7BKICKSTART_IP%7D/kickstart-postinstall/bin/kickstart-pre-install-g... -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://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS0_9600.c... -O /tmp/console.config grep -q "ttyS0,57600" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS0_57600.... -O /tmp/console.config grep -q "ttyS0,115200" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS0_115200... -O /tmp/console.config
grep -q "ttyS1,9600" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS1_9600.c... -O /tmp/console.config grep -q "ttyS1,57600" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS1_57600.... -O /tmp/console.config grep -q "ttyS1,115200" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/config/common/rhel_5/console/console_ttyS1_115200... -O /tmp/console.config
# Default to VGA if we can't find a serial console defined [ ! -f "/tmp/console.config" ] && wget http://$%7BKICKSTART_IP%7D/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://$%7BKICKSTART_IP%7D/config/common/rhel_5/network/ksdevice_eth0.config -O /tmp/network.config [ "$CURRENT_OS" == "RHEL5" ] && grep -q "ksdevice=eth1" /proc/cmdline && wget http://$%7BKICKSTART_IP%7D/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://$%7BKICKSTART_IP%7D/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://$%7BKICKSTART_IP%7D/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://$%7BKICKSTART_IP%7D/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://$%7BKICKSTART_IP%7D/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
On Tue, Jan 12, 2010 at 2:25 PM, nate centos@linuxpowered.net wrote:
Alan McKay wrote:
What am I missing here?
Is /bin/bash even available during %pre ?
I was wondering that myself, but it did not complain, and seems to run, and it is given as an example here :
http://fedoraproject.org/wiki/Anaconda/Kickstart
The following %pre script hangs on me - I get the little GUI window that comes up and says "Running pre-install scripts" and it hangs there
%pre #!/bin/sh # exec 1>&3 # exec > /dev/tty # chvt 3 # exec < /dev/tty3 > /dev/tty3 # clear SAVEPS3=$PS3 PS3="Use standard disk partitioning? " STDISK="" select STDISK in yes no do [ "$STDISK" != "" ] && break done PS3=$SAVEPS3 echo "# nothing" > /tmp/part-include
Alan McKay wrote:
The following %pre script hangs on me - I get the little GUI window that comes up and says "Running pre-install scripts" and it hangs there
Maybe a different approach? I set variables on the kickstart command line for custom options and have the installer evaluate those options. For example, by default all systems get a swap partition of 4GB. If I specify "swapsize=1024" as part of the install command line then that system gets a 1GB swap partition.
I think your %pre command is hanging because it's waiting for input.
nate
On Tue, Jan 12, 2010 at 2:45 PM, nate centos@linuxpowered.net wrote:
Maybe a different approach?
But this should work ...
I think your %pre command is hanging because it's waiting for input.
I think you are right, but I just don't get why it is behaving the way it is. Either hangs up front, or at the back end, depending on what I am doing.
There have to be people out there doing this. We always did it in my old job - that was with FC going on up to FC9
On Tue, Jan 12, 2010 at 2:38 PM, Alan McKay alan.mckay@gmail.com wrote:
The following %pre script hangs on me - I get the little GUI window that comes up and says "Running pre-install scripts" and it hangs there
[snip]
select STDISK in yes no do [ "$STDISK" != "" ] && break done PS3=$SAVEPS3 echo "# nothing" > /tmp/part-include
I'm not using any %pre, but have lots of %post scripts. None seem to work unless I put it all on one line. Even using the line continuation character fails.
For example, this fails: DISABLE_LIST="pcscd sendmail bluetooth" for item in ${DISABLE_LIST}; do chkconfig ${item} off done
But this works: .. for item in ${DISABLE_LIST}; do chkconfig ${item} off; done
On Tue, Jan 12, 2010 at 2:57 PM, Kwan Lowe kwan.lowe@gmail.com wrote:
But this works: .. for item in ${DISABLE_LIST}; do chkconfig ${item} off; done
Mine is working fine when I do this first :
chvt 3
But then when I get to the end it hangs. I am now trying to figure out what my console number was before that, so I can change back. I guess I could use trial and error. Unfortunately "fgconsole" does not seem to be present.
OK, at the end of my %pre I do
chvt 1
and it at least goes further and says it is starting the X server
1 ... 2 ... 3 ... (etc) started successfully
But it does not switch to it.
Which just reminded me that I could just run this in text mode! That would probably solve the problem, but now I'm being stubborn and want to get it going in X :-)
I'm just going to try chvt up to 10 and see if any of those works. If not, I'll switch to text mode.
Will report back ...
chvt 2 takes me to a root command prompt! from there I tried manually "chvt 3" which took me back where I was chvt 4 does not seem to do me any good 5 ... nada 6 ... now we're somewhere! It is coming back for me and giving me errors in my disk partitioning. Within the X GUI!
I think I have something to work with here ...
Just to confirm - working great!
Just have to do "chvt 2" at the beginning of the %pre to get into text mode, and then "chvt 6" at the end to flip back to X mode.
From: Alan McKay alan.mckay@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