LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-24-2009, 08:59 AM   #1
hgg2002
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?

Regards,
Herman.
 
Old 08-17-2009, 10:26 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,561
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
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:
Code:
# Path and name of kickstart file.
KS="/path/to/kickstart.ks"
# 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}"
    ;; 
 esac
done
...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).
 
  


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 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 07:15 AM
CentOS/Redhat kickstart packages cdestiny Linux - Server 4 12-02-2008 05:46 AM
[SOLVED] list of packages found in group selection in Kickstart stuart_cherrington Red Hat 3 09-11-2008 11:04 AM
A list of RedHat packages? rkfb Linux - Newbie 1 10-21-2003 05:23 PM
Redhat Kickstart Installation Colossalboom Linux - Software 0 08-21-2003 08:56 AM


All times are GMT -5. The time now is 01:48 PM.

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