1748157 Members
4193 Online
108758 Solutions
New Discussion юеВ

Re: %post not running

 
SOLVED
Go to solution
Benjamin Thompson
Occasional Advisor

%post not running

I haven't been able to resolve my kickstart CDROM issue, except by putting ks.cfg on a floppy and "linux expert ks=floppy". However, when I do ks.cfg from floppy, it doesn't execute the %post commands. Can I cut and paste the %post commands to a file and run it as a batch? How? Do I still need the "/mnt/sysimage" phrase if run from a batch(e.g. smp='rpm -qa -r /mnt/sysimage | grep kernel-smp | wc -l'), delete it for batch, or replace it with something else?

Basic stuff, I'm sure, but I'm very new to it all.
9 REPLIES 9
Stuart Browne
Honored Contributor

Re: %post not running

Show us what your 'ks.cfg' currently looks like.

A '%post' executes in the 'chroot' environment, so you don't need to redirect the root for rpm.
One long-haired git at your service...
Benjamin Thompson
Occasional Advisor

Re: %post not running

# Kickstart file automatically generated by anaconda.
interactive

install
lang en_US.UTF-8
langsupport --default en_US.UTF-8 en_US.UTF-8
#Probe for Mouse
#Probe for Video Card
rootpw --iscrypted XXXXXXXXXXXX
reboot
firewall --disabled
authconfig
timezone --utc America/Chicago
#Prompt for bootloader
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100
part pv.9 --size=4100 --grow
part swap --size=4096
volgroup Volume00 pv.9
logvol / --fstype ext3 --name=LogVol00 --vgname=Volume00 --size=4100 --grow

%packages
@ Everything
-firstboot
-kdebindings-devel
-kdebindings
-galeon
-plugger
-mozilla-devel
-mozilla
-mozilla-nspr
-mozilla-nspr-devel
-mozilla-chat
-mozilla-nss
-mozilla-nss-devel
-mozilla-psm
-mozilla-mail
-mozilla-dom-inspector
-mozilla-js-debugger

%post --nochroot
#Set up for install
#/mnt/sysimage is the hard drive
#/tmp/cdrom is the cdrom driver (if present)
#/dev/console is terminal 1
cddrv=/tmp/cdrom
# Determine cd device
if [ ! -e ${cddrv} ]
then
cddrv=`grep cdrom /proc/ide/*/media | sed -e "s/\/proc\/ide/\/dev/" | sed -e "s/\/media.*//"`
fi
echo "Post processing started" > /mnt/sysimage/tmp/rhks.log
cd /
mkdir /cdrom
#Move to terminal 1 cause that's where read looks for input
chvt 1
correctdisk=0
#Loop until they enter the correct cd
while [ ${correctdisk} -eq 0 ]
do
if [ ! -e /cdrom/ks.cfg ]
then
umount ${cddrv} > /dev/null 2>&1
echo "Message about to be delivered" >> /mnt/sysimage/tmp/rhks.log
echo "" > /dev/console
echo "" > /dev/console
echo "" > /dev/console
echo "Load the XiO boot disk into the CD drive and hit enter to continue" > /dev/console
read ans
echo "Message acknowledged" >> /mnt/sysimage/tmp/rhks.log
mount ${cddrv} /cdrom
else
correctdisk=1
fi
done
#Go to where messages will be written which is 3
chvt 3
echo "Loading additional files"
echo "Correct CD Mounted" >> /mnt/sysimage/tmp/rhks.log
#Determine if updating smp or not
smp=`rpm -qa -r /mnt/sysimage | grep kernel-smp | wc -l`
echo "smp is equal to " >> /mnt/sysimage/tmp/rhks.log
echo "${smp}" >> /mnt/sysimage/tmp/rhks.log
#rpmdb pkg expects /var/lib/rpm. Don't dissappoint them
ln -s /mnt/sysimage/var/lib/rpm /var/lib
#Load the correct set of rpm files
if [ ${smp} -ge 1 ]
then
rpm -Uvh --root /mnt/sysimage /cdrom/errata/comps.rpm /cdrom/errata/kernel-2.4.20-8.i686.rpm /cdrom/errata/initscripts-7.14-1.i386.rpm /cdrom/errata/kernel-source-2.4.20-8.i386.rpm /cdrom/errata/kernel-smp-2.4.20-8.i686.rpm /cdrom/errata/rhn-applet-2.0.9-0.9.0.1.i386.rpm /cdrom/errata/kernel-doc-2.4.20-8.i386.rpm /cdrom/errata/rpmdb-redhat-9-0.20030313.i386.rpm | tee -a /mnt/sysimage/tmp/rhks.log
else
rpm -Uvh --root /mnt/sysimage /cdrom/errata/comps.rpm /cdrom/errata/initscripts-7.14-1.i386.rpm /cdrom/errata/kernel-source-2.4.20-8.i386.rpm /cdrom/errata/kernel-2.4.20-8.i686.rpm /cdrom/errata/rhn-applet-2.0.9-0.9.0.1.i386.rpm /cdrom/errata/kernel-doc-2.4.20-8.i386.rpm /cdrom/errata/rpmdb-redhat-9-0.20030313.i386.rpm | tee -a /mnt/sysimage/tmp/rhks.log
fi
# Determine if bcm 5700 or not
bcm=`lsmod | grep bcm5700 | wc -l`
# Install bcm5700 if needed
if [ ${bcm} -ge 1 ]
then
rpm -ivh --root /mnt/sysimage /cdrom/bcm5700-6.0.2-1.i386.rpm | tee -a /mnt/sysimage/tmp/rhks.log
fi
#Clean up
echo "RPMs installed" >> /mnt/sysimage/tmp/rhks.log
umount ${cddrv}
echo "CD unmounted" >> /mnt/sysimage/tmp/rhks.log
chvt 7



BTW, thanks!
Stuart Browne
Honored Contributor
Solution

Re: %post not running

Do you get any output at all when using this ks routine?

I can't see anything out of place with it.

A few words however.

You don't need to make the symlink, as rpm has a dbpath flag:

rpm --root /mnt/sysimage --dbpath /mnt/sysimage/var/lib/rpm

Also, pretty much everything you've got here could be done in the chroot environment that usually gets set up (i.e. %post without the --chroot, thus removing the rpm's --root and --dbpath flags).
One long-haired git at your service...
Benjamin Thompson
Occasional Advisor

Re: %post not running

The ks.cfg ran as I would have expected, until it got to %post. The rhks.log which should have been written in the beginning of the %post wasn't even created. The anaconda-ks.cfg that is created from the responses to the installation stopped at "%post". There was nothing else on the line or following it.

In tinkering, I created a "post.txt" file on a floppy, mounted it, and ran "sh /floppy/post.txt". It APPEARS to have worked. I commented out lines from the ks.cfg that I didn't think I needed. It is as follows:

#Set up for install
#/tmp/cdrom is the cdrom driver (if present)
#/dev/console is terminal 1
#cddrv=/tmp/cdrom
# Determine cd device
#if [ ! -e ${cddrv} ]
#then
# cddrv=`grep cdrom /proc/ide/*/media | sed -e "s/\/proc\/ide/\/dev/" | sed -e "s/\/media.*//"`
#fi
cddrv=/dev/cdrom
echo "Post processing started" > /tmp/rhks.log
#cd /
mkdir /cdrom
mount /dev/cdrom /cdrom
#Move to terminal 1 cause that's where read looks for input
chvt 1
correctdisk=0
#Loop until they enter the correct cd
while [ ${correctdisk} -eq 0 ]
do
if [ ! -e /cdrom/ks.cfg ]
then
umount ${cddrv} > /dev/null 2>&1
echo "Message about to be delivered" >> /tmp/rhks.log
echo "" > /dev/console
echo "" > /dev/console
echo "" > /dev/console
echo "Load the XiO boot disk into the CD drive and hit enter to continue" > /dev/console
read ans
echo "Message acknowledged" >> /tmp/rhks.log
mount ${cddrv} /cdrom
else
correctdisk=1
fi
done
#Go to where messages will be written which is 3
#chvt 3
echo "Loading additional files"
echo "Correct CD Mounted" >> /tmp/rhks.log
#Determine if updating smp or not
smp=`rpm -qa | grep kernel-smp | wc -l`
echo "smp is equal to " >> /tmp/rhks.log
echo "${smp}" >> /tmp/rhks.log
#rpmdb pkg expects /var/lib/rpm. Don't dissappoint them
ln -s /var/lib/rpm /var/lib
#Load the correct set of rpm files
if [ ${smp} -ge 1 ]
then
rpm -Uvh /cdrom/errata/comps.rpm /cdrom/errata/kernel-2.4.20-8.i686.rpm /cdrom/errata/initscripts-7.14-1.i386.rpm /cdrom/errata/kernel-source-2.4.20-8.i386.rpm /cdrom/errata/kernel-smp-2.4.20-8.i686.rpm /cdrom/errata/rhn-applet-2.0.9-0.9.0.1.i386.rpm /cdrom/errata/kernel-doc-2.4.20-8.i386.rpm /cdrom/errata/rpmdb-redhat-9-0.20030313.i386.rpm | tee -a /tmp/rhks.log
else
rpm -Uvh /cdrom/errata/comps.rpm /cdrom/errata/initscripts-7.14-1.i386.rpm /cdrom/errata/kernel-source-2.4.20-8.i386.rpm /cdrom/errata/kernel-2.4.20-8.i686.rpm /cdrom/errata/rhn-applet-2.0.9-0.9.0.1.i386.rpm /cdrom/errata/kernel-doc-2.4.20-8.i386.rpm /cdrom/errata/rpmdb-redhat-9-0.20030313.i386.rpm | tee -a /tmp/rhks.log
fi
# Determine if bcm 5700 or not
bcm=`lsmod | grep bcm5700 | wc -l`
# Install bcm5700 if needed
if [ ${bcm} -ge 1 ]
then
rpm -ivh /cdrom/bcm5700-6.0.2-1.i386.rpm | tee -a /tmp/rhks.log
fi
#Clean up
echo "RPMs installed" >> /tmp/rhks.log
umount ${cddrv}
echo "CD unmounted" >> /tmp/rhks.log
chvt 7

The only error I got was the "ln -s /var/lib/rpm /var/lib", which was an error about not allowing the /var/lib/rpm to be overwritten.

Benjamin Thompson
Occasional Advisor

Re: %post not running

Opps. Messed up with the points and closed this. Still having issues. I put a few echo lines in the ks.cfg to send to the rhks.log file. So far the %post makes it down to and including the line prompting for the vendor CD (put an echo line to the log file right after it), however, the "chvt 1" doesn't happen and I never leave the graphical window. Thus, I don't see a prompt to change the CD or given the chance to press Enter in response to the "read ans". The %post stops, probably before (or while waiting for) the "read ans", since I typed 'echo "${ans}" >> /tmp/rhks.log' after it and nothing was placed in the log. I can only "assume" that a failure to respond to the prompt caused the %post to stop. Any ideas about why "chvt 1" didn't take me to the text window? Any idea about why the %post stopped?

Thanks again
Stuart Browne
Honored Contributor

Re: %post not running

If it got to the read, then I'd assume it's sitting there waiting for input.

As for 'chvt', I've honestly not seen or used the command before, so I can't really comment on why it didn't switch from an X-session (the man page says 'The key combination (Ctrl-)LeftAlt-F usually has a similar effect.'. I don't like the word 'usually' in that statement..

My first suggestion would be to get rid of the graphical interface by using 'text expert ks=floppy'.

As it's all automated anyway, why have a purdy-graphic-thingie *shrug*.
One long-haired git at your service...
Benjamin Thompson
Occasional Advisor

Re: %post not running

I ran ks.cfg from the floppy too. That was the case where it didn't run the %post completely. I tried to manually go to the VT1 with Ctrl-Alt-F1, but it just said it was going to sleep, which I took as a bad sign. Anyway, I set up a script to run the %post install routines with the "sh" command, and it worked.

Not being satisfied, I burned a DVD with RH9 CDs 1, 2, & 3 along with the vendor files under a directory labelled errata. I put the ks.cfg file in the top directory and the isolinux directory (that's what RH says to do in version 9). I tried running the CD ks.cfg from both the top and /isolinux directory. I was prompted for language, etc., which I shouldn't have been. I switched to VT3(?) it said it found the ks.cfg file, loaded it to /tmp/kickstart and proceeded to install. The problem is it started asking me questions that are all in the ks.cfg file, i.e. found it but did use it.

So, knowing the floppy kickstart was blowing past the prompt to change CD's or at least it never gave me the instruction to change, I decided to use the floppy again, but with the DVD (which had the vendor stuff on it). The install ran all the way through, anaconda showed "it's" "post installation" was completed and again it didn't ask for anything. After I thought it had failed again, without any warning of what was happening, without me touching any keys or showing a display of what was happening, it went to the DVD and started doing something. Well, it finished the vendor installation script. I wonder if this is an anaconda issue? I thought anaconda was supposed to track your inputs to create an anaconda-ks.cfg file. So, why did it show the "post installation" completing before it got to the ks.cfg %post processes? I guess the moral of the story is not to request a chvt and "read ans" to pause the system for a disc swap.
Stuart Browne
Honored Contributor

Re: %post not running

The 'interactive' at the top of your 'ks.cfg' would be why it was asking the questions.

I have to admit to not asking for input in a %post. I ask for input (successfully) in a %pre in the ks stuff I do here.
One long-haired git at your service...
Benjamin Thompson
Occasional Advisor

Re: %post not running

True, but the "interactive" is supposed to allow you to confirm the ks.cfg selections or change them. The selections I was getting weren't the ks.cfg file selections, but rather the default selections, as if the ks.cfg wasn't there.