# @(#)78 1.1 src/sysmgt/cfgassist/com/ibm/cfgassist/apps/wsmconfig/inst_query_utils.sh, cfgassist, websm720 7/15/11 03:09:18 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # websm720 src/sysmgt/cfgassist/com/ibm/cfgassist/apps/wsmconfig/inst_query_utils.sh 1.1 # # # # OBJECT CODE ONLY SOURCE MATERIALS # # COPYRIGHT International Business Machines Corp. 2000,2011 # All Rights Reserved # # The source code for this program is not published or otherwise # divested of its trade secrets, irrespective of what has been # deposited with the U.S. Copyright Office. # # IBM_PROLOG_END_TAG . wsminstallsh_msg.shh . winstsh_msg.shh DSPMSG=/usr/bin/dspmsg #--------------------------------------------------------------------------- # NAME: QueryTarget # # CALLED FROM: wsminstall.cpp and nim.res # # Displays a root node icon depending upon the caller, then generates # a list of installed software on the target represented by the root node # to be used by subsequent callers in a class hierarchy. #--------------------------------------------------------------------------- function QueryTarget { LIST_ALL=${1} TARGET=${2} TARGET_TYPE=${3} ALL_FILE=${4} PROD_FILE=${5} PKG_FILE=${6} TMPFILE=/tmp/nim.$$.discov case ${TARGET_TYPE} in master) ICON="p_server" ;; standalone) ICON="p_client" ;; spot) ICON="nim_spot" ;; non_NIM) ICON="p_client" ;; esac a_flag="" #----------------------------- # Query target for software... #----------------------------- [[ ${LIST_ALL} = true ]] && a_flag=a if [[ ${TARGET_TYPE} = non_NIM ]] then lslpp -Lqc${a_flag} > ${TMPFILE} 2>/tmp/query.stderr else nim -Fo lslpp -a lslpp_flags="-Lqc${a_flag}" ${TARGET} \ > ${TMPFILE} 2>/tmp/query.stderr fi RC=$? if [[ $RC -ne 0 ]] then # ------------------------------------------------------ # Send the contents of /tmp/query.stderr to stderr. The # framework will display this output in a error dialog. # ------------------------------------------------------ cat /tmp/query.stderr 1>&2 rm -f ${TMPFILE} /tmp/query.stderr return $RC fi sort -u ${TMPFILE} > ${ALL_FILE} rm -f ${TMPFILE} /tmp/query.stderr # isolate product names sed 's/[\.:].*//' ${ALL_FILE} | sort -u > ${PROD_FILE} # isolate package names cut -f1 -d: ${ALL_FILE} | sort -u > ${PKG_FILE} # NOTE: need to use dspmsg in the future... inst_software=$($DSPMSG -s ${MSG} winstsh.cat ${INST_SOFT} "Installed Software on %s" $TARGET) echo "${inst_software}" | wsmoutput -name - -icon $ICON } #--------------------------------------------------------------------------- # NAME: QueryProducts # # CALLED FROM: wsminstall.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the products listed # in the file passed in. #--------------------------------------------------------------------------- function QueryProducts { PROD_FILE=${1} cat ${PROD_FILE} 2>/dev/null | while read Name do Description=`get_desc ${Name}` echo "${Name}:${Name}:${Name} ${Description}" done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: QueryPackages # # CALLED FROM: wsminstall.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the packages of # the product PROD_NAME in the lslpp listing in the file passed in. #--------------------------------------------------------------------------- function QueryPackages { PKG_FILE=${1} PROD_NAME=${2} grep "^${PROD_NAME}\(\..*\)*\$" ${PKG_FILE} | while read Name do Description=`get_desc ${Name}` echo "${Name}:${Name}:${Name} ${Description}" done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: QueryFilesets # # CALLED FROM: wsminstall.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the filesets of # the packages in pkg_name in the lslpp listing in the file passed in. # May or may not show updates depending upon the caller. # # NOTE: The FixState variable can be one of the following: # # A - the fileset is in the apply state # B - the fileset is BROKEN # C - the fileset has been commited # ? - the fileset is INCONSISTENT # O - the fileset is OBSOLETE #--------------------------------------------------------------------------- function QueryFilesets { ALL_FILE=${1} pkg_name=${2} show_updates=${3} PrevFileset="" ICON="" DESCRIPTION="" [[ "${show_updates}" != true ]] && LeafNode=true IFS=: ( cat ${ALL_FILE} | \ grep "^${pkg_name}:" ; echo "##DONE##" ) | while read Package Fileset Level State PTF FixState Type Description DestDir Uninstaller MsgCatalog MsgSet MsgNum Parent do if [[ $PrevFileset != $Fileset && $PrevFileset != "" ]] then echo "$PrevFileset $PrevLevel ($DESCRIPTION):$PrevFileset:\c" echo "$ICON:$PrevLevel:$LeafNode:$OVERLAY:" ICON="" DESCRIPTION="" fi [[ $Package = "##DONE##" ]] && break PrevFileset="$Fileset" PrevState="$State" PrevLevel="$Level" [[ ${show_updates} = true ]] && LeafNode=false DESCRIPTION=$Description OVERLAY="" case "$FixState" in C) ICON="software_fileset" LeafNode=true ;; A) [[ ${show_updates} = true ]] && \ ICON="software_fix" || \ ICON="software_fileset" ;; B) # ---------------------------------------------------- # BROKEN STATE # This might be an update... but the user can only # correct this situation by removing the software or # by re-installing the software using the apply, commit, # no-save options. Therefore, we will not let the user # expand the node to the update level. # ---------------------------------------------------- ICON="software_fileset" OVERLAY="so_warning" LeafNode=true ;; '?') # ---------------------------------------------------- # INCONSISTENT STATE # If this is a fix, use the software_fileset icon. # Otherwise, use the software_fileset icon. # ---------------------------------------------------- if [[ $Type = "M" || $Type = "F" ]] ; then ICON="software_fileset" LeafNode=false else ICON="software_fileset" LeafNode=true fi OVERLAY="Frame_delete" ;; O) # ---------------------------------------------------- # OBSOLETE STATE # If this is a fix, use the software_fileset icon. # Otherwise, use the software_fileset icon. # ---------------------------------------------------- if [[ $Type = "M" || $Type = "F" ]] ; then ICON="software_fix" LeafNode=false else ICON="software_fileset" LeafNode=true fi OVERLAY="so_obsolete" ;; esac done | wsmoutput -header "VimNAME:FSName:VimICON:Level:VimLEAF:VimOVERLAY:" } #--------------------------------------------------------------------------- # NAME: QueryUpdates # # CALLED FROM: wsminstall.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the updates of # the packages in fset_name in the lslpp listing in the file passed in. #--------------------------------------------------------------------------- function QueryUpdates { ALL_FILE=${1} fset_name=${2} IFS=: cat ${ALL_FILE} | grep ":${fset_name}:" | while read \ Package Fileset Level State PTF FixState Type Description DestDir Uninstaller MsgCatalog MsgSet MsgNum Parent do if [[ $Type = "M" || $Type = "F" ]] ; then ICON="" OVERLAY="" case "$FixState" in A) ICON="software_fix" ;; B) ICON="bro_fix" ;; # NOT USED!!! '?') ICON="software_fix" OVERLAY="Frame_delete" ;; O) ICON="software_fix" OVERLAY="so_obsolete" ;; esac [[ $ICON != "" ]] && \ echo "$Fileset $Level:$Fileset:$ICON:$Level:$OVERLAY:" fi done | wsmoutput -header "VimNAME:FSName:VimICON:Level:VimOVERLAY:" } #--------------------------------------------------------------------------- # NAME: QAUTarget (Query Applied Updates) # # CALLED FROM: wsminstall.cpp and nim.res # # Displays a root node icon depending upon the caller, then generates # a lists of updates in the APPLIED state on the target represented by # the root node to be used by subsequent callers in a class hierarchy. #--------------------------------------------------------------------------- function QAUTarget { caller="${1}" target="${2}" target_type="${3}" out_file="${4}" if [[ ${caller} = NIM ]] then case ${target_type} in master) ICON="p_server" ;; spot) ICON="nim_spot" ;; *) ICON="p_client" ;; esac else target=`hostname` ICON=p_client fi # NOTE: need to use dspmsg in the future... applied_upd=$($DSPMSG -s ${MSG} winstsh.cat ${APPLIED_UPD} "Applied Updates on %s" $target) echo "${applied_upd}" | wsmoutput -name - -icon ${ICON} TMPFILE=/tmp/.inst.discov.$$ OLDLANG=${LANG} export LANG=C if [[ ${caller} = NIM ]] then nim -o lslpp -a lslpp_flags="qlac" ${target} > ${TMPFILE} else lslpp -qlac > ${TMPFILE} fi export LANG=${OLDLANG} grep APPLIED ${TMPFILE} | \ awk 'BEGIN {FS=":"} ($6 == "F") {print $2 " " $3 }' | \ sort -u > ${out_file} rm ${TMPFILE} return 0 } #--------------------------------------------------------------------------- # NAME: QAUUpdates (Query Applied Updates) # # CALLED FROM: install.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the applied but not # committed updates in lslpp listing in the file passed in. #--------------------------------------------------------------------------- function QAUUpdates { in_file="${1}" # need to handle situation where no updates were found! cat ${in_file} | while read Name do echo "${Name}:${Name}" done | wsmoutput -header "VimNAME:OptionName" } #--------------------------------------------------------------------------- # NAME: QFMTarget (Query Fixes on Media) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the fixes found on # the selected media. #--------------------------------------------------------------------------- function QFMTarget { CALLER="${1}" INPUT_DEVICE="${2}" DEVICE_TYPE="${3}" PROCESS_MULTIPLE="${4}" FILE="${5}" case "${DEVICE_TYPE}" in DIRECTORY) ICON="p_folder" ;; NETWORK) ICON="file" ;; LPP_SOURCE) ICON="file" ;; OTHER) case $(basename $INPUT_DEVICE) in cd*) ICON="resource_software" ;; rmt*) ICON="resource_backup" ;; fd*) ICON="diskette" ;; *) ICON="tb_open_up" ;; esac ;; esac # ----------------------------------------------------------- # Determine the state of the "Process multiple volume" option # and set the S_FLAG variable appropriately for the browse. # ----------------------------------------------------------- if [[ "${PROCESS_MULTIPLE}" = "false" ]] ; then S_FLAG="-S" else S_FLAG="" fi TMPFILE=/tmp/.fix.out.$$ if [[ "${CALLER}" = NIM ]] then nim -o showres \ -a sm_inst_flags="instfix_list" ${INPUT_DEVICE} > ${TMPFILE} else if [[ "${DEVICE_TYPE}" != "NETWORK" ]] then /usr/lib/instl/sm_inst instfix_list -d ${INPUT_DEVICE} ${S_FLAG} > ${TMPFILE} else nimclient -o showres -a instfix_flags=T \ -a resource=${INPUT_DEVICE} > ${TMPFILE} fi fi # Replace : with - because colon is used as separation key in websm app cat ${TMPFILE} | sed -e "s/:/-/g" | awk '/^[IX]/ { FIX=$1 for (i = 2; i <= NF; i++) { if (i == 2) comm=$i; else comm=comm " " $i; } printf("%s (%s)\n", FIX, comm); }' > $FILE rm -f ${TMPFILE} fixes_on=$($DSPMSG -s ${MSG} winstsh.cat ${FIXES_ON} "Fixes on %s" $INPUT_DEVICE) echo "${fixes_on}" | wsmoutput -name - -icon ${ICON} } #--------------------------------------------------------------------------- # NAME: QFMFixes (Query Fixes on Media) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the fixes found on # the selected media. #--------------------------------------------------------------------------- function QFMFixes { FILE="${1}" cat $FILE | while read Name do echo "${Name}:${Name}" done | wsmoutput -header "VimNAME:OptionName" } #--------------------------------------------------------------------------- # NAME: colon_separate_sm_inst_output # # CALLED FROM: QueryDevice # # Parses the input file provided and converts to a colon-separated output form. # EXAMPLE: Converts output such as the following: # A ALL @@A _all_filesets # @ 4.1.2.0 Description for A.obj 04.01.0002.0000 @@A.obj 4.1.2.0 # # B ALL @@B _all_filesets # + 4.1.2.0 Description for A.obj 04.01.0002.0000 @@B.obj 4.1.2.0 # + 4.1.0.0 Description for B.obj 04.01.0000.0000 @@B.obj 4.1.0.0 # # To: # # A:A.obj:4.1.2.0::I:C:::::N:Description for A.obj 04.01.0002.0000 ::::+ # B:B.obj:4.1.2.0::I:T:::::N:Description for A.obj 04.01.0002.0000 ::::+ # B:B.obj:4.1.0.0::I:T:::::N:Description for B.obj 04.01.0000.0000 ::::+ # # NOTES: # 1. There's no way of distinguishing between a base level and update so # we'll just assume everything is a base level. We could assume nonzero # 'f' in v.r.m.f implies update to narrow it down but we'll occasionally # be wrong and we'll draw attention to the fact that a non-zero 'm' # will never be marked as a fix, which could frequently be wrong. # 2. We'll always set the state of anything with a '@' symbol to committed (C), # otherwise it's in the .toc (T). # 3. We'll use a state variable to tell us what we should be looking for # when parsing. # - state = 1 means we're looking for a "package name line" # or a line in which the _all_filesets keyword appears. # - state = 2 means we're within a section of the output looking at # the fileset and update entries for a specific package. # When parsing in state 2, if the first field of the line only has # 1 character, we can be fairly sure that it's licensing information or # the installed status symbol (@). #--------------------------------------------------------------------------- function colon_separate_sm_inst_output { in_file=${1} awk 'BEGIN { state=1 pkg_name="" } (index($1,"#") == 1) \ { # skip comments and reset the state state=1; next } ($1 == "") { # skip blank lines and reset the state state=1; next } (state == 1) { # Looking for a line containing the pkg_name if (match($0, "_all_filesets") > 0) { # Found it. Isolate the pkg_name. split ($0,l_rhs,":"); split (l_rhs[2],rhs, " "); pkg_name=rhs[1]; state = 2; } next } (state == 2) { # Isolate the fileset name and level from # the right hand side of the line. split ($0, l_rhs, ":"); split (l_rhs[2],rhs, " "); fs_name=rhs[1]; level=rhs[2]; # isolate license/state info and remember # where description starts (always after level) sz=split(l_rhs[1], lhs, " "); sz=sz-1; if (length(lhs[1]) == 1) { lic_info=lhs[1]; desc_start=3; } else { lic_info=""; desc_start=2; } # Set the installed state if (lic_info == "@") { status="C"; lic_info="+"; } else status="T"; # Print the first part of the converted output printf ("%s:%s:%s::I:%s:::::N:", pkg_name, fs_name, level, status); # Print the description for (i=1; i<=sz; i++) { if (i>=desc_start) printf ("%s ",lhs[i]); } # Print the rest of the line. printf ("::::%s\n", lic_info); } ' ${in_file} return $? } #--------------------------------------------------------------------------- # NAME: QueryDevice # # CALLED FROM: wsminstall.cpp and nim.res # # Displays a root node icon depending upon the caller, then generates # a list of software on the device specified. The list will be used # by subsequent callers in a class hierarchy. #--------------------------------------------------------------------------- function QueryDevice { caller="${1}" which_dialog="${2}" browse_filtered="${3}" packages="${4}" input_device="${5}" device_type="${6}" target="${7}" process_multiple="${8}" vim_tmpfile="${9}" list_file="${10}" prod_file="${11}" pkg_file="${12}" opt_file="${13}" SM_INST=/usr/lib/instl/sm_inst SM_NIM=/usr/lpp/bos.sysmgt/nim/methods/m_sm_nim NIMCLIENT=/usr/sbin/nimclient PRODTMPFILE=/tmp/.prod.list.$$ PKGTMPFILE=/tmp/.pkg.list.$$ OPTTMPFILE=/tmp/.opt.list.$$ case ${device_type} in DIRECTORY) ICON="tb_open_up" ;; NETWORK) ICON="file" ;; LPP_SOURCE) ICON="file" ;; OTHER) case $(basename $input_device) in cd*) ICON="resource_software" ;; rmt*) ICON="resource_backup" ;; fd*) ICON="diskette" ;; *) ICON="tb_open_up" ;; esac ;; esac # ----------------------------------------------------------- # Determine the state of the "Process multiple volume" option # and set the S_FLAG variable appropriately for the browse. # ----------------------------------------------------------- if [[ "${process_multiple}" = "false" ]] ; then S_FLAG="-S" else S_FLAG="" fi # ------------------------------------------------------- # Check to see if we need to ignore the installation # state of the software when browsing. We do this for # NIM's bos install dialog because there is no reference # machine with which we can compare the installed software # We also do it for the install_dialog when the input source # for a SPOT is tape or CD because NIM doesn't know how to # browse CDs. # ------------------------------------------------------- ignore_install_state="" if [[ ${which_dialog} = bos_install_dialog ]] || [[ ${which_dialog} = install_dialog_NIM_device_browse ]] then ignore_install_state=true # Disable multi-volume processing for a device browse from # NIM since NIM does not support multi-volume CDs. # This prevents browsing from one toc on the CD and installing from # another (which is prone to failure). [[ ${which_dialog} = install_dialog_NIM_device_browse ]] && S_FLAG="-S" # proceed as if browsing from the install_dialog which_dialog=install_dialog fi QUERY="" if [[ ${which_dialog} = install_dialog ]] then if [[ "${browse_filtered}" = "true" ]] then [[ ${caller} = NIM ]] && \ QUERY="list_latest_filesets" || QUERY="-f _all_latest" else [[ ${caller} = NIM ]] && \ QUERY="list_all_filesets" || QUERY="-f _all_available" fi elif [[ "${which_dialog}" = "install_packages_dialog" ]] then for pkg in `echo ${packages} | sed 's/\// /g'` do QUERY="${QUERY} -p ${pkg}" done fi # ----------------------------- # Query device for software... # ----------------------------- if [[ ${caller} != NIM ]] then if [[ ${device_type} != "NETWORK" ]] then ${SM_INST} list_filesets -C ${S_FLAG} ${QUERY} \ -d ${input_device} > ${vim_tmpfile} 2>/tmp/query.stderr RC=$? else ${NIMCLIENT} -o showres \ -a sm_inst_flags="list_filesets -C ${QUERY}" \ -a resource=${input_device} > ${vim_tmpfile} 2>/tmp/query.stderr RC=$? fi else # ------------------------------------------------------------------ # Only AIX 4.3.0 (and later) know about the -C flag to sm_inst. # For NIM targets, we must first check the installed level # of BOS on the target machine or target SPOT to see if # we'll need to do our own parsing of the sm_inst output. # ------------------------------------------------------------------ DO_COLONS= if [[ ${target} = master ]] then DO_COLONS="-C" else # get the level of bos.rte level=`nim -o lslpp -a lslpp_flags="-Ou -qlc bos.rte" \ ${target} | cut -f3 -d':' 2>/dev/null` # Make sure we found something that looks like a level before # continuing, otherwise we'll do our own colon separated parsing. if [[ ${level} = *.*.*.* ]] then release_ver=`echo ${level} | cut -f1 -d.` release_lev=`echo ${level} | cut -f2 -d.` if [ ${release_ver} -gt 4 ] || [ ${release_ver} -eq 4 -a ${release_lev} -ge 3 ] then DO_COLONS="-C" else if [ ${release_ver} -eq 4 -a ${release_lev} -lt 2 ] then print \ $DSPMSG -s ${MSG} winstsh.cat ${EARLY_BASE_OS} "The target machine is installed with a level of the base \noperating system that is earlier than 4.2. NIM browse\ncapability is only supported on machines installed with a base\noperating system of 4.2 or later." 1>&2 return -1 fi fi fi fi ${SM_NIM} ${QUERY} ${DO_COLONS} -l ${input_device} -t ${target} \ > ${vim_tmpfile} 2>/tmp/query.stderr RC=$? if [[ ${RC} -eq 0 ]] && [[ -z ${DO_COLONS} ]] then colon_separate_sm_inst_output ${vim_tmpfile} \ > ${list_file} 2>/tmp/query.stderr RC=$? cp ${list_file} ${vim_tmpfile} fi fi if [[ $RC -eq 0 ]] then sort -u ${vim_tmpfile} > ${list_file} if [[ ${ignore_install_state} = true ]] then # Replace the state code with a "T" to indicate that the # software is on the media. For convenience, we browsed with # respect to the software installed on the master, but we # don't really care about its state and don't want to create # confusion. awk 'BEGIN {FS=":"} { \ printf ("%s:%s:%s:%s:%s:T:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n", \ $1,$2,$3,$4,$5,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)\ }' ${list_file} > ${vim_tmpfile} cp ${vim_tmpfile} ${list_file} fi rm -f ${vim_tmpfile} OIFS=${IFS} IFS=: cat ${list_file} | \ while read Name Fileset Level State Type FixState PTF Description DestDir Uninstaller MsgCatalog MsgSet MsgNum Parent do echo "${Name}.@@" >> ${PRODTMPFILE} echo "${Name}">> ${PKGTMPFILE} echo "${Name}:${Fileset}:${Description}:${Type}" >> ${OPTTMPFILE} done sed 's/[\.:].*@@//' ${PRODTMPFILE} | sort -u > ${prod_file} sort -u ${PKGTMPFILE} > ${pkg_file} sort -t: -k1,2 -u ${OPTTMPFILE} > ${opt_file} rm -f ${PRODTMPFILE} ${PKGTMPFILE} ${OPTTMPFILE} else # -------------------------------------------------------------- # Send the contents of /tmp/query.stderr to stderr. # framework will display this output in an error dialog # -------------------------------------------------------------- cat /tmp/query.stderr 1>&2 rm -f /tmp/query.stderr return $RC fi IFS=${OIFS} rm -f /tmp/query.stderr echo "$(echo "$input_device" | sed 's/:/\\:/g')" | \ wsmoutput -name - -icon $ICON } #--------------------------------------------------------------------------- # NAME: QueryFilesetsAndUpdates # # CALLED FROM: wsminstall.cpp and nim.res # # Generates websm stanzas in wsmoutput format for the filesets and # updates matching the package name passed in, in the file passed in. #--------------------------------------------------------------------------- function QueryFilesetsAndUpdates { parent_name="${1}" opt_name="${2}" temp_file="${3}" list_file="${4}" opt_file="${5}" app_name="${6}" FixIcon=""; StatusText=""; FixClass="" ThisOption=${opt_name} PARENT_AND_OPT="" IFS=':' if [[ "${parent_name}" != "" ]] then PARENT_AND_OPT="^${parent_name}:${ThisOption}" fi cat ${opt_file} | grep "${PARENT_AND_OPT}" | while read junk OptName junkDesc do # ------------------------------------------------------ # This helps resolve the perf_agent packaging problem... # ------------------------------------------------------ cat ${list_file} | grep "${PARENT_AND_OPT}" > ${temp_file} # -------------------------------------- # Get filesets and updates from $OptName # -------------------------------------- IFS=':' awk -F: -v FilesetName=${OptName} '$2 == FilesetName { print $2 ":" $3 ":" $5 ":" $6 ":" $12 ":" $16 }' ${temp_file} | while read FixName FixLevel FixType FixStatus OptDesc LicenseState do OVERLAY="" case ${FixType} in I) case ${FixStatus} in A|C) FixIcon=software_fileset OVERLAY=so_check ;; *) FixIcon=software_fileset ;; esac FixClass=WebSM.apps.${app_name}.BaseLevelFileset ;; S|*) case ${FixStatus} in A|C) FixIcon=software_fix OVERLAY=so_check ;; *) FixIcon=software_fix ;; esac FixClass=WebSM.apps.${app_name}.SelectiveFix ;; esac FixLongName="${FixName} ${FixLevel} (${OptDesc})" # ---------------------------------------------------- # Determine if a software license overlay is necessary # ---------------------------------------------------- case ${LicenseState} in "?") # "Licensing information unavailable" OVERLAY=Frame_licenseunav ;; "!") # "No license found" OVERLAY=Frame_licensenone ;; "$") # "License found" OVERLAY=Frame_licenseok ;; esac echo "${FixName}:${FixLongName}:${FixIcon}:${StatusText}:${FixClass}:${OVERLAY}:" done | wsmoutput -header "OptionName:VimNAME:VimICON:FixStatus:VimCLASS:VimOVERLAY:" done } #--------------------------------------------------------------------------- # NAME: QBFFTarget (Query Backup Images) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the bff images found on # the selected media. This generates a single tree view of images. # Used by the "Copy Software to Disk" dialog. #--------------------------------------------------------------------------- function QBFFTarget { INPUT_DEVICE="${1}" DEVICE_TYPE="${2}" PROCESS_MULTIPLE="${3}" ALL_FILE="${4}" PROD_FILE="${5}" TARGET="${6}" case "${DEVICE_TYPE}" in DIRECTORY) ICON="tb_open_up" ;; OTHER) case $(basename $INPUT_DEVICE) in cd*) ICON="resource_software" ;; rmt*) ICON="resource_backup" ;; fd*) ICON="diskette" ;; *) ICON="tb_open_up" ;; esac ;; esac # ----------------------------------------------------------- # Determine the state of the "Process multiple volume" option # and set the S_FLAG variable appropriately for the browse. # ----------------------------------------------------------- if [[ "${PROCESS_MULTIPLE}" = "false" ]] ; then S_FLAG="-S" else S_FLAG="" fi # Set a command prefix depending upon whether or not # we'll be running the command locally or on a remote # NIM server. cmd_prefix="ksh -c " if [[ -n ${TARGET} ]] then # Must be working with a NIM lpp_source We need to # rsh the commands to the lpp_source server if it isn't # the NIM master. server=`lsnim -Z -a server ${TARGET} | \ awk 'BEGIN {FS=":"} (NR > 1){print $2}'` if [[ ${server} != master ]] then server_host_name=`lsnim -Z -a if1 ${server} | \ awk 'BEGIN {FS=":"} (NR > 1){print $3}'` cmd_prefix="/usr/bin/rsh ${server_host_name} " fi fi ${cmd_prefix} "gencopy -Ld ${INPUT_DEVICE}" > $ALL_FILE 2>/dev/null # get the product and package name cut -f 2 -d: $ALL_FILE | sort -u > $ALL_FILE.new cat $ALL_FILE.new | sed 's/:/ /' > $PROD_FILE pkg_sw=$($DSPMSG -s ${MSG} winstsh.cat ${PKGS_ON} "Packages on %s" $INPUT_DEVICE) echo "${pkg_sw}" | wsmoutput -name - -icon $ICON } #--------------------------------------------------------------------------- # NAME: QBFFProducts (Query Backup Images) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the products found on # the selected media. #--------------------------------------------------------------------------- function QBFFProducts { FILE="${1}" cat $FILE | while read Name do Description=`get_desc ${Name}` echo "${Name}:${Name}:${Name} ${Description}" done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: QBFFImages (Query Backup Images) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the packages found on # the selected media. #--------------------------------------------------------------------------- function QBFFImages { FILE="${1}" PROD_NAME="${2}" grep "^${PROD_NAME}" $FILE | while read Package Fileset do Description=`get_desc ${Fileset}` if [[ ${PROD_NAME} = ${Package} ]] then echo "${Package}:${Package}:${Package} ${Description}" fi done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: QBCTarget (Query Bundle Contents) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the software listed in a # user or system defined bundle. #--------------------------------------------------------------------------- function QBCTarget { bundle="${1}" file="${2}" caller="${3}" if [[ ${caller} != NIM ]] ; then SYS_BUNDLE_DIR=/usr/sys/inst.data/sys_bundles USER_BUNDLE_DIR=/usr/sys/inst.data/user_bundles ls ${SYS_BUNDLE_DIR}/${bundle}.bnd > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then cat ${SYS_BUNDLE_DIR}/${bundle}.bnd | grep -v "^#" > $file fi ls ${USER_BUNDLE_DIR}/${bundle}.bnd > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then cat ${USER_BUNDLE_DIR}/${bundle}.bnd | grep -v "^#" > $file fi else nim -o showres ${bundle} | grep -v "^#" > $file 2>/dev/null fi echo "$bundle\c" } #--------------------------------------------------------------------------- # NAME: QBCProducts (Query Bundle Contents) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the software found in # a selected software bundle. #--------------------------------------------------------------------------- function QBCProducts { FILE="${1}" cat $FILE | sed 's/:/,/g' | awk '{printf "%s:",$0}' } #--------------------------------------------------------------------------- # NAME: QPPMDevice (Query Products and Packages on Media) # # CALLED FROM: wsminstall.cpp # # Generates websm stanzas in wsmoutput format for the products and packages # found on the selected input device. This code is used by the "List # Supplemental Fileset Info" dialog. #--------------------------------------------------------------------------- function QPPMDevice { input_device="${1}" device_type="${2}" prod_file="${3}" pkg_file="${4}" list_file="${5}" vim_tmpfile="${6}" SM_INST=/usr/lib/instl/sm_inst SM_NIM=/usr/lpp/bos.sysmgt/nim/methods/m_sm_nim NIMCLIENT=/usr/sbin/nimclient QUERY="-f _all_available" PRODTMPFILE=/tmp/.prod.list.$$ PKGTMPFILE=/tmp/.pkg.list.$$ case ${device_type} in DIRECTORY) ICON="tb_open_up" ;; NETWORK) ICON="file" ;; LPP_SOURCE) ICON="file" ;; OTHER) case $(basename $input_device) in cd*) ICON="resource_software" ;; rmt*) ICON="resource_backup" ;; fd*) ICON="diskette" ;; *) ICON="tb_open_up" ;; esac ;; esac # ---------------------------- # Query device for software... # ---------------------------- if [[ ${device_type} != "NETWORK" ]] then ${SM_INST} list_filesets -C ${QUERY} \ -d ${input_device} > ${vim_tmpfile} 2>/tmp/query.stderr RC=$? else ${NIMCLIENT} -o showres \ -a sm_inst_flags="list_filesets -C ${QUERY}" \ -a resource=${input_device} > ${vim_tmpfile} 2>/tmp/query.stderr RC=$? fi if [[ $RC -eq 0 ]] then sort -u ${vim_tmpfile} > ${list_file} rm -f ${vim_tmpfile} # -------------------------------- # Get the products and packages... # -------------------------------- IFS=: cat ${list_file} | \ while read Name Fileset Level State PTF FixState Type Description do if [[ ${Type} = "J" ]] then echo "${Name}" >> ${PRODTMPFILE} else echo "${Name}" >> ${PRODTMPFILE} echo "${Name}" >> ${PKGTMPFILE} fi done sed 's/[\.:].*//' ${PRODTMPFILE} | sort -u > ${prod_file} sort -u ${PKGTMPFILE} > ${pkg_file} rm -f ${PRODTMPFILE} ${PKGTMPFILE} else # -------------------------------------------------------------- # Display the contents of /tmp/query.stderr # -------------------------------------------------------------- cat /tmp/query.stderr 1>&2 rm -f /tmp/query.stderr return $RC fi rm -f /tmp/query.stderr ${list_file} echo "$(echo "$input_device" | sed 's/:/\\:/g')" | \ wsmoutput -name - -icon $ICON } #--------------------------------------------------------------------------- # NAME: QPPMProduct (Query Products and Packages on Media) # # CALLED FROM: wsminstall.cpp #--------------------------------------------------------------------------- function QPPMProduct { FILE="${1}" cat $FILE | while read Name do Description=`get_desc ${Name}` echo "${Name}:${Name}:${Name} ${Description}" done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: QPPMPackage (Query Products and Packages on Media) # # CALLED FROM: wsminstall.cpp #--------------------------------------------------------------------------- function QPPMPackage { PKG_FILE=${1} PROD_NAME=${2} grep "^${PROD_NAME}\(\..*\)*\$" ${PKG_FILE} | while read Name do Description=`get_desc ${Name}` echo "${Name}:${Name}:${Name} ${Description}" done | wsmoutput -header "VimNAME:OptionName:LongName" } #--------------------------------------------------------------------------- # NAME: WriteFile # # PURPOSE: Used to create a file with the list of software to install # and/or a file with the names of the available software to # install from the media source. # # CALLED FROM: Install_UpdateDialog.java # #--------------------------------------------------------------------------- function WriteFile { SW_FILE=${1} SW_LIST=${2} `touch ${SW_FILE}` # Regardless of how we selected media, we need to put user choices # in a file so we know what to install. echo "${SW_LIST}" >${SW_FILE} } #--------------------------------------------------------------------------- # NAME: checkClient # # PURPOSE: Used to check that a NIM client is responding # # CALLED FROM: nim install wizard # #--------------------------------------------------------------------------- function checkClient { CLIENT=${1} rsh ${CLIENT} echo >/dev/null 2>&1 result=$? return $result }