LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 08-16-2009, 01:51 AM   #1
johnnymta
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Rep: Reputation: 0
kickstart - asking for configuration in the %pre section


Hi guys!

First post here, be nice...

I am preparing a kickstart for CentOS 5.3 in my company, and we want to be able to install the product the same way in several servers, but some parameters will vary between different customers we'll ship the product to - for example the root password, or some inner product-related parameters.

One way to solve this is to just burn a new CD with a new configuration file in it for each customer installing our product, but this is a little pain if we're going to ship CDs to 5 different customers every day. It would be much better if in the pre-installation i could ask some questions and process the answers later in the post installation.

I tried to do something like that:
Code:
%pre
chvt 2
exec </dev/tty2 1>/dev/tty2 2>/mnt/sysimage/root/ks-preinstall-errors.log

echo "-- Passowrd configuration --"
stty -echo

ROOTPW=""
while [ "$ROOTPW" == "" ]; do

    echo -n "Enter desired root password: "
    read rootpw
    echo -n "Confirm password: "
    root rootpw2
    if [ "$rootpw" == "$rootpw2" ]; then
        ROOTPW=$rootpw
    else
        echo "Passwords do not match! Try again..."
    fi
done

echo "ROOTPW=$ROOTPW" > /tmp/answers.txt

stty echo

chvt 6
exec </dev/tty6 1>/dev/tty6
of course there are some other arguments, and then i do something like
Code:
. /tmp/answers.txt
in the %post --nochroot and continue from there...


Anyhow, this doesn't really work - the 'chvt 2' changes to tty2, but doesn't write or gets input from user, and the pre install script just goes on.
Looking at the /tmp/anaconda.log during installation shows the message:
ERROR : Error code 1 encountered running a kickstart %pre/%post script


Anybody has an idea how to fix this?

Thank you very much!
 
Old 08-16-2009, 09:57 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Hi johnymta,

I think anaconda has already allocated tty2 for use and its not interactive, you need to choose an unused one like tty6

eg.

%pick_a_section_here
exec < /dev/tty6 > /dev/tty6
chvt 6


# prompt user for info here


#finished
chvt 1


cheers,

kbp
 
Old 08-16-2009, 01:51 PM   #3
aviso
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Rep: Reputation: 1
I tried something like this a while ago and remember something where the input and output weren't on the terminals you expected, so I wond up having to redirect them with >>. I don't think I still have that code, but if I find it, I'll post what I did.

I actually dropped this approach and instead set everything in the kickstart file for generic value and then wrote scripts that ran on firstboot to configure the server. The benefit of this was I could configure everything at once and then still had the scripts available in case someone fat-fingered something.

I've seen where other people pregenerate kickstart files on another server, then select that file for the build. This of course requires you to configure the network, easiest way is with dhcp.
 
Old 08-17-2009, 03:29 AM   #4
johnnymta
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Original Poster
Rep: Reputation: 0
Thanks for the answers, However - It actually didn't help... I tried severals ttys, and tried to switch between graphical and text mode - doesn't help...

I think the key issue here might be the error in the log:

ERROR : Error code 1 encountered running a kickstart %pre/%post script

What does error code 1 means?
I think after the chvt command there's an error and the rest of the %pre script doesn't actually work...

This is very frustrating...

The firstboot solution will probably work fine - but then the installation of the system couldn't be really unattended enough (in the case configuration is done at the %pre stage you can go have lunch after that and come back with a fully configured system...)
 
Old 08-17-2009, 09:31 AM   #5
aviso
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Rep: Reputation: 1
I found what I had. And as I said, I didn't wind up using this in the end, but you should be able to add something like this to %pre:
Code:
clear >/dev/tty1
echo >/dev/tty1
echo -n "Server Name: " >/dev/tty1
read SERVERNAME
echo -n "IP Address: " >/dev/tty1
read IPADDRESS
Then you should be able to reference everything with $SERVERNAME. $IPADDRESS, etc. At least in %pre. Then you can commit whatever else you need to a file.

If you find you need more flexibility than standard shell scripts allow, you might try using python, which should already be in the build environment or miniperl, which you can compile and then dump in a separate directory on the disk.
 
Old 08-18-2009, 01:15 AM   #6
johnnymta
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Original Poster
Rep: Reputation: 0
Thanks a lot! This helps a little... I'm close to finding what really was my problem (I have a theory).

BTW, if you don't know - if you want to configure only hostname and IP you can do it by using 'bootproto=query' in the 'network' configuration in the kickstart file...
 
Old 08-18-2009, 01:34 AM   #7
johnnymta
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Original Poster
Rep: Reputation: 0
As I thought...
'2>/mnt/sysimage/root/ks-preinstall-errors.log' was the problem...

maybe this is because system is readonly at the %pre section or something...

Or maybe it was the 'clear' command that helped?

I wish anaconda will give a more detailed log in the case of such errors...

simply doing
'exec </dev/tty8 >/dev/tty8' instead of what i wrote at the beginning solved the problem...

Thanks for your help guys!

Last edited by johnnymta; 08-18-2009 at 01:37 AM.
 
Old 08-18-2009, 03:22 AM   #8
aviso
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Rep: Reputation: 1
Glad you got it working.

I think '2>/mnt/sysimage/root/ks-preinstall-errors.log' failed because sysimage wouldn't be mounted at this point. If you want to log errors, you'll have to save it somewhere else, such as /tmp/ which sits in RAM and then copy it over during %post.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
%post section of Fedora8 kickstart install doesn't run scott.anderson Fedora - Installation 2 07-31-2008 08:41 AM
problem with kickstart post section Hairman Red Hat 2 05-14-2007 01:35 PM
Kickstart and %pre on RHAS V4.0 yuri65 Red Hat 0 07-19-2005 06:41 AM
Using parted in the pre section of my kickstart install davidr Linux - Software 0 12-09-2004 06:53 PM
Kickstart %pre not executing rajatgarg Linux - General 0 01-12-2004 12:16 PM


All times are GMT -5. The time now is 06:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration