Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-24-2009, 07:59 AM   #1
LQ Newbie
Registered: Jul 2009
Distribution: CentOS5.3
Posts: 1

Rep: Reputation: 0
How to automate installation of a list of packages in redhat (like kickstart)

I have a kickstart file for RedHat, but I can't remake the os installation, so I just need to ensure that the packages included in the kickstart file are installed automatically if required.

Any idea about how to do it?

Old 08-17-2009, 09:26 AM   #2
Registered: May 2001
Posts: 29,358
Blog Entries: 55

Rep: Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545
The packages section of your kickstart file is marked by the tags "%packages" and "%end", so if 'egrep -m2 -n "%(packages|end)" /path/to/kickstart.ks' should return two line numbers (say 19 and 121), so if you sed -n '20,120p' /path/to/kickstart.ks|grep -ie "^[a-z0-9@-]" you'll have the groups (prefixed by the "at" sign), deinstallations (prefixed with a minus sign) and package names. Tying it together it could look something like:
# Path and name of kickstart file.
# Determination of section start and end.
SECTION=($(egrep -m2 -n "%(packages|end)" ${KS}|awk -F':' '{print $1}'))
# Retrieve package list.
eval echo "sed -n '$[${SECTION[0]}+1],$[${SECTION[1]}-1]p' ${KS}"|sh|grep -ie "^[a-z0-9@-]" | while read LINE; do 
 # What to do if LINE does not match expectation.
 ARRAY=(${LINE}); [ ${#ARRAY[@]} -eq 1 ] || { echo "Line \"${LINE}\" contains  ${#ARRAY[@]} items, skipping."; break; }
 # LINE now should contain single item of groupname or packagename.
 case "${LINE}" in
   @*) # For groups check name.
       GROUP=$(grep -m1 -i "${LINE:1:255}" /usr/share/doc/rpm-*/GROUPS||echo "${LINE:1:255}")
       echo rpm -i -g \"${GROUP}\"
   -*) # For ausradierung we dont check anything!
       echo rpm -e "${LINE}"
    *) # Just install.
       echo rpm -i "${LINE}"
...which would only echo commands. Once you have determined it would be OK to run (I'm not sure about the group names, haven't checked with F10/F11) change "echo rpm" to "rpm" or "yum -y" (I wonder if that should be 'yum groupinstall' for groups?).

As always YMMV(VM).


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to configure redhat linux kickstart installation amin_shaikh32 Linux - Newbie 6 01-28-2012 06:15 AM
CentOS/Redhat kickstart packages cdestiny Linux - Server 4 12-02-2008 04:46 AM
[SOLVED] list of packages found in group selection in Kickstart stuart_cherrington Red Hat 3 09-11-2008 10:04 AM
A list of RedHat packages? rkfb Linux - Newbie 1 10-21-2003 04:23 PM
Redhat Kickstart Installation Colossalboom Linux - Software 0 08-21-2003 07:56 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:07 PM.

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