#! /bin/sh # Erik Jacobson # # This script will create a temporary yum config file pointed at this # directory in case you prefer to use command line tools to install as # opposed to print and system-cdinstall-helper. # # Since Rhel6.0, system-cdinstall-helper is no longer available. # Most customers should use this script. # # First, we need to figure out the path to the CD. MY_NAME=${0##*/} BASE=/etc/yum.conf cfg=${CFG:-/tmp/yum-hpe.conf} err=0 relfile=/etc/redhat-release discinfo=.discinfo MediaPath= MediaName= [ -r $cfg ] && echo NOTICE: ${cfg} already exist. New configuration will be appended. [ -f $cfg -a ! -w $cfg ] && echo WARNING: ${cfg} write permissions. Exiting. && exit 1 [ "${0:0:1}" = "/" ] && MediaPath=$(dirname $0) [ "${0:0:2}" = ".." ] && MediaPath= [ "${0:0:2}" = "./" ] && MediaPath=$(pwd) [ -z "$MediaPath" ] \ && echo "ERROR: Please run ${MY_NAME} like this:" \ && echo " /path/to/media/${MY_NAME}" \ && err=$(( $err + 1 )) \ || echo "Using media path: $MediaPath" ! [ -r $relfile ] \ && echo "ERROR: no $relfile file. Is this a RHEL system?" \ && err=$(( $err + 1 )) \ || echo Redhat Release: $(cat $relfile ) discinfo="${MediaPath}/$discinfo" ! [ -r $discinfo ] \ && echo "ERROR: no $discinfo file. Please check your media." \ && err=$(( $err + 1 )) \ || MediaName=$(cat $discinfo | head -2 | tail -1 | tr '/ ' '--' ) [ -z "$MediaName" ] \ && echo "ERROR: Cannot determine media name using $discinfo." \ && err=$(( $err + 1 )) \ || echo "Using media name: ${MediaName}" [ $err -ne 0 ] \ && echo "NOTICE: $err error(s) found. Exiting." \ && exit 1 # Create temporary yum configuration file. if [ ! -s $cfg -o ! -f $cfg ] ; then [ -r ${BASE} ] \ && cp ${BASE} ${cfg} \ || echo WARNING: $BASE read permission. Not using it. fi # Find available yum groups xml=${MediaPath}/RPMS/comps.xml groups=( "Cannot be determined. Please use: yum grouplist." ) if [ ! -r ${xml} ] ; then echo "WARNING: ${xml} not found or no read permissions." echo " Cannot display available groups for installation." else IFS='^' groups=(`grep '' RPMS/comps.xml \ | sed -re 's/[[:space:]]*<[/]*name>//g' \ | sort -u \ | sed -e 's/^/"/' -e 's/$/"^/' \ | tr -d '\n'` ) [ ${#groups[@]} -eq 0 ] \ && groups=( "Cannot be determined. Please use: yum grouplist." ) fi # Create repo if need be. grep -qE "\[${MediaName}\]" $cfg \ && echo WARNING: ${MediaName} entry already exist. No entry added to $cfg. \ || cat <<-ENDREPO >> $cfg [${MediaName}] # Available Groups: $( for (( i=0; i < ${#groups[@]}; i++)) ; do printf "# %s\n" "${groups[i]}"; done) # name=${MediaName} baseurl=file://$MediaPath/RPMS enabled=1 gpgkey=file://$MediaPath/RPM-GPG-KEY-sgi file://$MediaPath/RPM-GPG-KEY-hpe gpgcheck=1 ENDREPO # Talk about how to use the config file a bit. cat <&2 =============================================================================== How to use $cfg =============================================================================== A temporary yum config file has is available as ${cfg}. You can use this config file with the system yum command to install from this media. Note you can add additional media(s) to ${cfg}, ie.: # cd /path/to/another_media # ./${MY_NAME} Here are some example yum commands you may look in to. Available Groups: $( for (( i=0; i < ${#groups[@]}; i++)) ; do printf " %s\n" "${groups[i]}"; done ) List all groups available for installation: # yum -c ${cfg} grouplist Install a group, in this example : ${groups[0]} # yum -c ${cfg} groupinstall ${groups[0]} Note: Be sure to install all the groups you need; the above is just an example. You can use the 'grouplist' command to find the available group choices, and select from that list. DONE exit 0