#!/usr/bin/ksh # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # vxpref - CGI script to view the patchdiag.xref file from Sun # # Author: Bernd Schemmer, Bernd.Schemmer@gmx.de # # credits: Heiner Steven (heiner.steven@odn.de) # # History: 03/08/2005 0.0.1 /bs - initial release # 03/09/2005 0.0.2 /bs - minor enhancements # 04/04/2005 0.0.3 /bs - made the local patch directory variabel # massiv performance enhancements # 04/06/2005 0.0.4 /bs - minor performance enhancements # 06/13/2005 0.0.5 /bs - corrected a bug in the handling of obsolete patches # # # # Installation: Copy the script to the cgi-bin directory of your web server # # Usage: create a link for the script without any parameter # # License: Freeware # # disable filename globbing set -f __VERSION="0.0.5" __SCRIPTNAME="${0##*/}" AUTHOR="Bernd Schemmer" AUTHOR_EMAIL_ADDRESS="Bernd.Schemmer@gmx.de" AUTHOR_MESSAGE="

vxpref version ${__VERSION}.
written by ${AUTHOR}, ${AUTHOR_EMAIL_ADDRESS}

" AUTHOR_MESSAGE_SHORT="

vxpref version ${__VERSION}.
(c) ${AUTHOR_EMAIL_ADDRESS}

" # change the following variables to your need # PATCHDIAG_XREF_FILE_DIR="/export/install/tools" PATCHDIAG_XREF_FILE="${PATCHDIAG_XREF_FILE_DIR}/patchdiag.xref" LOCAL_PATCH_DIRECTORY="/export/install/All_Patches" ### ----------------------------------------------------------------- ### Subroutines # # Code for ConvertString based on a script from # Heiner Steven (heiner.steven@odn.de) # ConvertString() { echo "$1" | awk ' BEGIN { hextab ["0"] = 0; hextab ["8"] = 8; hextab ["1"] = 1; hextab ["9"] = 9; hextab ["2"] = 2; hextab ["A"] = hextab ["a"] = 10 hextab ["3"] = 3; hextab ["B"] = hextab ["b"] = 11; hextab ["4"] = 4; hextab ["C"] = hextab ["c"] = 12; hextab ["5"] = 5; hextab ["D"] = hextab ["d"] = 13; hextab ["6"] = 6; hextab ["E"] = hextab ["e"] = 14; hextab ["7"] = 7; hextab ["F"] = hextab ["f"] = 15; if ("'"$EncodedLF"'" == "yes") EncodedLF = 1; else EncodedLF = 0 } { decoded = "" i = 1 len = length ($0) while ( i <= len ) { c = substr ($0, i, 1) if ( c == "%" ) { if ( i+2 <= len ) { c1 = substr ($0, i+1, 1) c2 = substr ($0, i+2, 1) if ( hextab [c1] == "" || hextab [c2] == "" ) { print "WARNING: invalid hex encoding: %" c1 c2 | \ "cat >&2" } else { code = 0 + hextab [c1] * 16 + hextab [c2] + 0 #print "\ncode=", code c = sprintf ("%c", code) i = i + 2 } } else { print "WARNING: invalid % encoding: " substr ($0, i, len - i) } } else if ( c == "+" ) { # special handling: "+" means " " c = " " } decoded = decoded c ++i } if ( EncodedLF ) { printf "%s", decoded # no line newline on output } else { print decoded } } ' - } ### ----------------------------------------------------------------- # old and not alaways working version XConvertString() { typeset SRC_STRING="$*" bash -c "printf '$( echo "$( echo "${SRC_STRING}" | tr "+" " " )" | sed 's/%/\\x/g' )' " } ### ----------------------------------------------------------------- ## substr ## ## get a substring of a string ## ## usage: variable=$( substr sourceStr pos length ) ## or substr sourceStr pos length resultStr ## ## returns: 1 - parameter missing ## 0 - parameter okay ## substr() { typeset resultstr="" typeset THISRC=1 if [ "$1"x != ""x ] ; then typeset s=$1 typeset p=$2 typeset l=$3 [ "$l"x = ""x ] && l=${#s} [ "$p"x = ""x ] && p=1 resultstr="$( echo $s | cut -c${p}-$((${p}+${l}-1)) )" THISRC=0 else THISRC=1 resultstr="$1" fi if [ "$4"x != ""x ] ; then eval $4=\"${resultstr}\" else echo ${resultstr} fi return ${THISRC} } ### ----------------------------------------------------------------- LogMsg() { typeset THISMSG="$*" [ "${PAGE_TYPE}" = "html" ] && echo "${THISMSG}
" || echo "${THISMSG}" } ### ----------------------------------------------------------------- LogErrorMsg() { typeset THISMSG="$*" LogMsg "ERROR: ${THISMSG}" } ### ----------------------------------------------------------------- LogWarningMsg() { typeset THISMSG="$*" LogMsg "WARNING: ${THISMSG}" } ### ----------------------------------------------------------------- LogInfoMsg() { typeset THISMSG="$*" LogMsg "INFO: ${THISMSG}" } ### ----------------------------------------------------------------- GetXrefFileVersion() { typeset THISFILE="$1" typeset XREF_VERSION="" typeset XREF_HEADER_MARKER="## PATCHDIAG TOOL CROSS-REFERENCE FILE AS OF" if [ -f ${PATCHDIAG_XREF_FILE} ] ; then XREF_VERSION=$( grep "${XREF_HEADER_MARKER}" ${THISFILE} ) XREF_VERSION=${XREF_VERSION#*AS OF} XREF_VERSION=${XREF_VERSION%*##} fi echo ${XREF_VERSION} } ### ----------------------------------------------------------------- PrintPageHeader() { if [ "${PAGE_TYPE}" = "html" ] ; then cat < Patchdiag xref EOT else cat <" echo "" else echo "" fi } ### ----------------------------------------------------------------- PrintEmptyFrame() { PrintPageHeader PrintPageFooter } ### ----------------------------------------------------------------- PrintFrameSet() { cat < Patchdiag.xref - Analyse EOT return 0 } ### ----------------------------------------------------------------- PrintNewsPage() { PrintPageHeader cat < ${AUTHOR_MESSAGE} If you are using ${__SCRIPTNAME} the first time on this server please check the prerequisites. before using it
Please be aware that this script does NOT check the input for backquotes! This maybe a security hole in your environment!
News        History

News

date version author comment
04/01/2005 0.0.3 /bs made the local patch directory variable;
much better performance now

Back to top


History

f
date version authorcomment
04/01/2005 0.0.3 /bs made the local patch directory variable;
much better performance now
03/07/2005 0.0.2 /bs still work in progress
03/04/2005 0.0.1 bs initial release

Back to top

EOT PrintPageFooter } ### ----------------------------------------------------------------- Print_NavigationFrame() { # get possible OS versions typeset OS_VERSIONS="" typeset HW_VERSIONS="" typeset CURENTRY="" typeset PATCHFILE_MSG="" typeset PRINT_NAME="" OS_VERSIONS="$( grep -v '#' ${PATCHDIAG_XREF_FILE} | cut -f8 -d '|' | sort | uniq )" if [ -f "${PATCHDIAG_XREF_FILE}" ] ; then PRINT_NAME="${PATCHDIAG_XREF_FILE##*/}" PATCHFILEMSG="
View ${PRINT_NAME}
Current version: $( GetXrefFileVersion ${PATCHDIAG_XREF_FILE} )
" else PATCHFILEMSG="Warning: Patchdiag.xref file not found
" fi # create the html code for the OS listbox OS_LISTBOX="" # create the html code for the architecture listbox # HW_VERSIONS="$( grep -v "^#" ${PATCHDIAG_XREF_FILE} | cut -f9 -d "|" | tr ";" " " | tr " " "\n" | grep -v "^[0-9]" | grep -v "^ $" | sort | uniq)" HW_VERSIONS="$( grep -v "^#" ${PATCHDIAG_XREF_FILE} | cut -f9 -d "|" | tr ";" "\n" | grep -v "^[0-9]" | grep -v "^ $" | sort | uniq)" HW_LISTBOX="" cat < Patchdiag.xref - Analyse Navigation Download patchdiag.xref
Use Proxy
${AUTHOR_MESSAGE_SHORT} ${PATCHFILEMSG} Sun
Sunsolve
Sun Patch Portal

Select the OS version
${OS_LISTBOX}

Select the Architecture
${HW_LISTBOX}

Search patches for (use a leding - to exclude a word)

Case sensitiv Debug

Select the type of patches:
only not n/a
Recommended
Security
Obsolete
Withdrawn
exist local
Local Patch directory:

Proxyuser:
Proxypwd:



Download a patch
Patch Number:

Signed Patch yes no
Download via ftp http

View Readme
Get Patch
EOT return 0 } ### ----------------------------------------------------------------- ViewPatchDiagxref() { [ ! -f ${PATCHDIAG_XREF_FILE} ] && die 1 "Patchdiag xref file ${PATCHDIAG_XREF_FILE} not found" PAGE_TYPE="ascii" PrintPageHeader cat ${PATCHDIAG_XREF_FILE} PrintPageFooter } ### ----------------------------------------------------------------- PrintPatchListFrame() { typeset CURWORD="" typeset STARTTIME="" typeset ENDTIME="" typeset GREP_STARTTIME="" typeset GREP_ENDTIME="" typeset PRINT_STARTTIME="" typeset PRINT_ENDTIME="" typeset P_EXCLUDE_WORDS="" typeset P_INCLUDE_WORDS="" typeset HELPSTRING="" [ ! -f ${PATCHDIAG_XREF_FILE} ] && die 1 "Patchdiag xref file ${PATCHDIAG_XREF_FILE} not found" PrintPageHeader if [ 1 = 0 ] ; then echo "
ACTION= \"${ACTION}\" " echo "
PATCH_ARC = \"${PATCH_ARC}\" " echo "
PATCH_OS = \"${PATCH_OS}\" " echo "
RECOMMENDED_PATCH = \"${RECOMMENDED_PATCH}\" " echo "
SECURITY_PATCH = \"${SECURITY_PATCH}\" " echo "
OBSOLETE_PATCH = \"${OBSOLETE_PATCH}\" " echo "
WITHDRAWN_PATCH = \"${WITHDRAWN_PATCH}\" " echo "
PATCH_MUST_EXIST_LOCAL = \"${PATCH_MUST_EXIST_LOCAL}\" " echo "
FREETEXT= \"${FREETEXT}\" " echo "
SEARCHSTRING= \"${SEARCHSTRING}\" " fi STARTTIME=$( date -u ) grep -v "^#" ${PATCHDIAG_XREF_FILE} | tr "!" "." | tr "|" "!" >${TMPFILE1} LIST_OF_PATCHES="" echo > "${TMPFILE3}" GREP_CMD="" # [ "${PATCH_OS}"x != ""x ] && GREP_CMD="${GREP_CMD} | grep \"${PATCH_OS}\" " # [ "${PATCH_ARC}"x != ""x ] && GREP_CMD="${GREP_CMD} | grep \"${PATCH_ARC}\" " for CURWORD in ${PATCH_OS} ; do GREP_CMD="${GREP_CMD} | grep \"${CURWORD}\" " done for CURWORD in ${PATCH_ARC} ; do GREP_CMD="${GREP_CMD} | grep \"${CURWORD}\" " done [ "${RECOMMENDED_PATCH}"x = "R"x ] && GREP_CMD="${GREP_CMD} | grep \"!R!\" " [ "${RECOMMENDED_PATCH}"x = "r"x ] && GREP_CMD="${GREP_CMD} | grep -v \"!R!\" " [ "${SECURITY_PATCH}"x = "S"x ] && GREP_CMD="${GREP_CMD} | grep \"!S!\" " [ "${SECURITY_PATCH}"x = "s"x ] && GREP_CMD="${GREP_CMD} | grep -v \"!S!\" " [ "${OBSOLETE_PATCH}"x = "O"x ] && GREP_CMD="${GREP_CMD} | grep \"!O!\" " [ "${OBSOLETE_PATCH}"x = "o"x ] && GREP_CMD="${GREP_CMD} | grep -v \"!O!\" " [ "${WITHDRAWN_PATCH}"x = "B"x ] && GREP_CMD="${GREP_CMD} | grep \"B!\" " [ "${WITHDRAWN_PATCH}"x = "b"x ] && GREP_CMD="${GREP_CMD} | grep -v \"B!\" " if [[ "${CASE_SENSITIVE}" == "Y" ]] ; then GREP_OPTIONS="" else GREP_OPTIONS="-i" fi for CURWORD in ${SEARCHSTRING} ; do # GREP_CMD="${GREP_CMD} | grep ${GREP_OPTIONS} \"${CURWORD}\" " substr "${CURWORD}" 1 1 CURSTR substr "${CURWORD}" 2 100 CURSTR1 case ${CURSTR} in "+" ) GREP_CMD="${GREP_CMD} | grep ${GREP_OPTIONS} \"${CURSTR1}\" " P_INCLUDE_WORDS="${P_INCLUDE_WORDS} ${CURSTR1}" ;; "-" ) GREP_CMD="${GREP_CMD} | grep ${GREP_OPTIONS} -v \"${CURSTR1}\" " P_EXCLUDE_WORDS="${P_EXCLUDE_WORDS} ${CURSTR1}" ;; * ) GREP_CMD="${GREP_CMD} | grep ${GREP_OPTIONS} \"${CURWORD}\" " P_INCLUDE_WORDS="${P_INCLUDE_WORDS} ${CURWORD}" ;; esac done if [ "${DEBUG_SEARCH}"x = "Y"x ] ; then echo "
" echo "The grep command used is \"${GREP_CMD}\" " echo "
" fi # [ "${SEARCHSTRING}"x != ""x ] && GREP_CMD="${GREP_CMD} | grep \"${SEARCHSTRING}\" " if [ "${P_INCLUDE_WORDS}"x != ""x ] ; then HELPSTRING="${HELPSTRING} Searching for: ${P_INCLUDE_WORDS}
" fi if [ "${P_EXCLUDE_WORDS}"x != ""x ] ; then HELPSTRING="${HELPSTRING} Ignoring lines containing: ${P_EXCLUDE_WORDS}
" fi cat <
The list of patches (e.g for using in a script or something similar) and the statistics of the search are at the end of this page
${HELPSTRING}
EOT if [[ ${PATCH_MUST_EXIST_LOCAL} != "" ]] ; then if [ -d "${LOCAL_PATCH_DIRECTORY}" ] ; then echo "Using the local patch directory \"${LOCAL_PATCH_DIRECTORY}\"" else echo "WARNING: THe local patch directory \""${LOCAL_PATCH_DIRECTORY}"\" does not exist" fi echo "
" fi GREP_STARTTIME="$( date )" eval "cat ${TMPFILE1} ${GREP_CMD} >${TMPFILE2}" 2>/dev/null GREP_ENDTIME="$( date )" # ls -l ${TMPFILE2} # echo "
" grep "^##" ${PATCHDIAG_XREF_FILE} | while read d0 ; do echo "${d0}
" done oIFS="º{IFS}" IFS="!" export IFS cat < Patch
Revision
Release
exists local?
Rec.
Security
Obsolete
Withdrawn
OS
arc
pkgs
Description
EOT PRINT_STARTTIME="$( date)" while read __PATCHNO __PATCHREV __PATCHDATE __PATCH_REC __PATCH_SEC __PATCH_OBSOLETE __PATCH_WITHDRAWN \ __PATCH_OS __PATCH_ARC __PATCH_PKGS __PATCH_DESC ; do [[ ! -z ${PATCH_ARC} && ! ${__PATCH_ARC} == *${PATCH_ARC}* ]] && continue [[ ! -z ${PATCH_OS} && ! ${__PATCH_OS} == *${PATCH_OS}* ]] && continue [[ ${RECOMMENDED_PATCH} = "R" && ! ${__PATCH_REC} = "R" ]] && continue [[ ${RECOMMENDED_PATCH} = "r" && ${__PATCH_REC} = "R" ]] && continue [[ ${SECURITY_PATCH} = "S" && ! ${__PATCH_SEC} = "S" ]] && continue [[ ${SECURITY_PATCH} = "s" && ${__PATCH_SEC} = "S" ]] && continue [[ ${OBSOLETE_PATCH} = "O" && ! ${__PATCH_OBSOLETE} = "O" ]] && continue [[ ${OBSOLETE_PATCH} = "o" && ${__PATCH_OBSOLETE} = "O" ]] && continue [[ ${WITHDRAWN_PATCH} = "B" && ! ${__PATCH_WITHDRAWN} == *B ]] && continue [[ ${WITHDRAWN_PATCH} = "b" && ${__PATCH_WITHDRAWN} == *B ]] && continue # echo "${__PATCH_OS} ${__PATCH_REC} ${__PATCH_SEC} ${__PATCH_OBSOLETE} ${__PATCH_WITHDRAWN}" # if [[ ${SEARCHSTRING} != "" ]] ; then # for CURWORD in ${SEARCHSTRING} ; do # [[ ! "${__PATCHNO} ${__PATCHREV} ${__PATCHDATE} ${__PATCH_REC} ${__PATCH_SEC} ${__PATCH_OBSOLETE} ${__PATCH_WITHDRAWN} ${__PATCH_OS} ${__PATCH_ARC} ${__PATCH_PKGS} ${__PATCH_DESC}" == *${CURWORD}* ]] && continue # done # fi if [[ -z ${PATCH_MUST_EXIST_LOCAL} ]] ; then if [[ -d ${LOCAL_PATCH_DIRECTORY}/${__PATCHNO}-${__PATCHREV} ]] ; then __PATCH_EXISTS_ON_LOCAL_FS="Y" [[ ${PATCH_MUST_EXIST_LOCAL} = "N" ]] && continue else __PATCH_EXISTS_ON_LOCAL_FS="NO" [[ ${PATCH_MUST_EXIST_LOCAL} = "Y" ]] && continue fi fi # LIST_OF_PATCHES="${LIST_OF_PATCHES} ${__PATCHNO}-${__PATCHREV}" # (( NO_OF_PATCHES=NO_OF_PATCHES+1 )) echo "${__PATCHNO}-${__PATCHREV}">>"${TMPFILE3}" (( NO_OF_PATCHES=NO_OF_PATCHES+1 )) oIFS="${IFS}" IFS=";" set -- ${__PATCH_ARC} if [[ $# > 0 ]] ; then CUR_ARCS=$1 shift fi while [[ $# > 0 ]] ; do CUR_ARCS="${CUR_ARCS}
$1" shift done IFS="${oIFS}" oIFS="${IFS}" IFS=";" set -- ${__PATCH_PKGS} if [[ $# > 0 ]] ; then CUR_PKGS="$1" shift fi while [[ $# > 0 ]] ; do CUR_PKGS="${CUR_PKGS}
$1" shift done IFS="${oIFS}" cat < ${__PATCHNO}-${__PATCHREV} http ftp
signed:
http ftp ${__PATCHREV}
${__PATCHDATE}
${__PATCH_EXISTS_ON_LOCAL_FS}
${__PATCH_REC}
${__PATCH_SEC}
${__PATCH_OBSOLETE}
${__PATCH_WITHDRAWN}
${__PATCH_OS}
${CUR_ARCS}
${CUR_PKGS}
${__PATCH_DESC}
EOT # ${__PATCHNO}-${__PATCHREV}
done <${TMPFILE2} IFS="${oIFS}" PRINT_ENDTIME="$( date)" echo "" echo "" echo "
" ENDTIME=$( date -u ) cat <

Search Statistics

Search started at: ${STARTTIME}
Search ended at: ${ENDTIME}
Patches found: ${NO_OF_PATCHES}

EOT if [ "${DEBUG_SEARCH}"x = "Y"x ] ; then cat < Grep started at: ${GREP_STARTTIME}
Grep ended at: ${GREP_ENDTIME}

Print started at: ${PRINT_STARTTIME}
Print ended at: ${PRINT_ENDTIME}

EOT fi cat <Back to top

List of patches


The list of patches on this page is (${NO_OF_PATCHES} patches found):

$( cat "${TMPFILE3}" )

Back to top
EOT PrintPageFooter return 0 } ### ----------------------------------------------------------------- CheckRequirements() { # PAGE_TYPE="text" typeset WGET_BINARY="" typeset REQ_OK=0 PrintPageHeader LogMsg "${AUTHOR_MESSAGE}" LogMsg "

Checking requirements ...

" LogMsg "This script is executed by the user \"${__USERID}\"." LogMsg "

Checking the directories ...

" # if [ -d "${LOCAL_PATCH_DIRECTORY}" ] ; then # LogMsg "OK, the local patch directory \"${LOCAL_PATCH_DIRECTORY}\" exists." # else # LogWarningMsg "The local patch directory \"${LOCAL_PATCH_DIRECTORY}\" does NOT exist." # LogMsg "" # REQ_OK=2 # fi if [ -d "${PATCHDIAG_XREF_FILE_DIR}" ] ; then LogMsg "OK, the directory for the xref file \"${PATCHDIAG_XREF_FILE_DIR}\" exists." if [ -f ${PATCHDIAG_XREF_FILE} ] ; then touch "${PATCHDIAG_XREF_FILE}" 2>/dev/null THISRC=$? else touch "${PATCHDIAG_XREF_FILE}" 2>/dev/null THISRC=$? rm "${PATCHDIAG_XREF_FILE}" 2>/dev/null fi if [ ${THISRC} -ne 0 ] ; then LogErrorMsg "Can not write to the directory \"${PATCHDIAG_XREF_FILE_DIR}\"" LogInfoMsg "Make sure, that the user ${__USERID} can write in this directory" LogMsg "" fi touch "${PATCHDIAG_XREF_FILE}.$$" 2>/dev/null if [ $? -ne 0 ] ; then LogErrorMsg "Can not write the file \"${PATCHDIAG_XREF_FILE}.$$\"" LogInfoMsg "Make sure, that the user ${__USERID} can create new files in the directory \"${DIRNAME}\" " LogMsg "" else rm "${PATCHDIAG_XREF_FILE}.$$" 2>/dev/null fi else LogErrorMsg "The directory for the xref file \"${PATCHDIAG_XREF_FILE_DIR}\" does NOT exist" LogInfoMsg "Either create the directory or change the variable PATCHDIAG_XREF_FILE_DIR in the script" LogMsg "" REQ_OK=2 fi touch "${TMPFILE1}" 2>/dev/null if [ $? -eq 0 ] ; then LogMsg "OK, can create and write to the temporary file \"${TMPFILE1}\" " else LogErrorMsg "Can NOT create and write to the temporary file \"${TMPFILE1}\" " LogInfoMsg "Either change the permissions of the directory $(dirname ${TMPFILE1} ) or change the variable TMPFILE1 in the script" LogMsg "" REQ_OK=1 fi touch "${TMPFILE2}" 2>/dev/null if [ $? -eq 0 ] ; then LogMsg "OK, can create and write to the temporary file \"${TMPFILE2}\" " else LogErrorMsg "Can NOT create and write to the temporary file \"${TMPFILE2}\" " LogInfoMsg "Either change the permissions of the directory $(dirname ${TMPFILE2} ) or change the variable TMPFILE2 in the script" LogMsg "" REQ_OK=1 fi LogMsg "

Checking the binaries ...

" which wget | read WGET_BINARY dummy if [ "${WGET_BINARY}" = "no" ] ; then LogErrorMsg "Can not find wget in the PATH. " LogInfoMsg "Make sure that wget is reachable via the PATH variable" LogMsg "" REQ_OK=1 else LogMsg "OK, wget is available via the PATH variable" fi which awk | read AWK_BINARY dummy if [ "${AWK_BINARY}" = "no" ] ; then LogErrorMsg "Can not find awk in the PATH. " LogInfoMsg "Make sure that awk is reachable via the PATH variable" LogMsg "" REQ_OK=1 else LogMsg "OK, awk is available via the PATH variable" fi if [ -f "${PATCHDIAG_XREF_FILE}" ] ; then LogMsg "OK, the patchdiag xref file \"${PATCHDIAG_XREF_FILE}\" exist." else LogWarningMsg "The patchdiag xref file \"${PATCHDIAG_XREF_FILE}\" does NOT exist." LogMsg "Please retrieve the patchdiag.xref file via the Get patchdiag.xref button and reload the navigation via the Reload Script button before doing anything else." fi LogMsg "

----- Result: -----

" if [ ${REQ_OK} != 0 ] ; then LogErrorMsg "Please correct the errors before using this script" LogMsg "" else LogMsg "OK, you can start using this script" LogMsg "" fi PrintPageFooter } ### ----------------------------------------------------------------- DownloadPatch() { typeset METHOD="" [ "${PATCH_NO}"x = ""x ] && die 1 "No patchnumber entered" PrintPageHeader PATCH_ID=${PATCH_NO%-*} PATCH_REV=${PATCH_NO#*-} if [ "${DOWNLOAD_METHOD}"x = "ftp"x ] ; then METHOD="f" else METHOD="h" fi if [ "${DOWNLOAD_SECURITY}"x = "Y"x ] ; then METHOD="${METHOD}s" fi if [ "${SUBACTION}"x = "download"x ] ; then cat <
If the automatic redirection does not work, you can use this link to download the patch ${PATCH_NO}
EOT else cat <
If the automatic redirection does not work, you can use this link to view the readme of the patch ${PATCH_NO}
EOT fi PrintPageFooter } ### ----------------------------------------------------------------- RetrievePatchDiagxref() { typeset THISRC=0 typeset XREF_VERSION="" typeset BACKUP_FILE="${PATCHDIAG_XREF_FILE}.$$" typeset WGET_PARAMETER="" PAGE_TYPE="text" PrintPageHeader # LogMsg "USEPROXY=\"${USEPROXY}\"" # LogMsg "PROXYUSR=\"${PROXYUSR}\"" # LogMsg "PROXYPWD=\"${PROXYPWD}\"" if [ "${USEPROXY}"x = "YES"x ] ; then PROXYUSR=$( ConvertString ${PROXYUSR} ) PROXYPWD=$( ConvertString ${PROXYPWD} ) WGET_PARAMETER="--proxy-user=${PROXYUSR} --proxy-passwd=${PROXYPWD}" else if [ "${PROXYPWD}"x != ""x -o "${PROXYUSR}"x != ""x ] ; then LogMsg "Warning: Proxyuser or Proxypassword entered but Proxy Check box not ticked!" fi fi # LogMsg "USEPROXY=\"${USEPROXY}\"" # LogMsg "PROXYUSR=\"${PROXYUSR}\"" # LogMsg "PROXYPWD=\"${PROXYPWD}\"" LogMsg "Downloading the current patchdiag.xref file to \"${PATCHDIAG_XREF_FILE}\" " if [ ${THISRC} = 0 ] ; then if [ -f ${XREF_DOWNLOAD_LOCKFILE} ] ; then LogErrorMsg "Another download of the xref file is still running; can not run another." cat ${XREF_DOWNLOAD_LOCKFILE} THISRC=1 else echo "xref file download started at $( date ) " >${XREF_DOWNLOAD_LOCKFILE} if [ $? -ne 0 ] ; then LogErrorMsg "Can not create the lock file \"${XREF_DOWNLOAD_LOCKFILE}\"" THISRC=1 fi fi fi if [ ${THISRC} = 0 ] ; then which wget | read WGET_BINARY dummy if [ "${WGET_BINARY}" = "no" ] ; then LogErrorMsg "Can not find wget in the PATH. Please check the error and try again" THISRC=1 fi fi if [ ${THISRC} = 0 ] ; then if [ -f ${PATCHDIAG_XREF_FILE} ] ; then LogInfoMsg "The existing patchdiag.xref file is from $( GetXrefFileVersion ${PATCHDIAG_XREF_FILE} )" LogMsg "Creating a backup of the existing file in \"${BACKUP_FILE}\" ..." mv ${PATCHDIAG_XREF_FILE} ${BACKUP_FILE} if [ $? -ne 0 ] ; then LogErrorMsg "Error creating a backup of the existing file. Please check the error and try again." THISRC=1 fi else LogInfoMsg "There is no existing patchdiag.xref file" fi fi if [ ${THISRC} = 0 ] ; then LogMsg "Calling wget ..." wget "http://patches.sun.com/reports/patchdiag.xref" ${WGET_PARAMETER} -O "${PATCHDIAG_XREF_FILE}" THISRC=$? if [ ! -s "${PATCHDIAG_XREF_FILE}" -o ${THISRC} != 0 ] ; then LogErrorMsg "Error downloading the new patchdiag.xref file" rm "${PATCHDIAG_XREF_FILE}" 2>/dev/null if [ -f ${BACKUP_FILE} ] ; then LogMsg "Now restoring the old version " mv ${BACKUP_FILE} ${PATCHDIAG_XREF_FILE} else LogErrorMsg "Restoring of the old version not possible - No backup version found" fi THISRC=1 else LogInfoMsg "New patchdiag.xref successfully downloaded." LogInfoMsg "The new patchdiag.xref file is from $( GetXrefFileVersion ${PATCHDIAG_XREF_FILE} )" rm ${BACKUP_FILE} 1>/dev/null 2>/dev/null LogMsg "" LogMsg "Please reload the navigation via the \"Reload Script\" button before doing anything else." LogMsg "" fi fi PrintPageFooter return 0 } ### ----------------------------------------------------------------- PrintErrorPage() { typeset ERRORMSG=$* PrintPageHeader cat <

${__SCRIPTNAME} - ERROR

${ERRORMSG}

EOT PrintPageFooter return 0 } ### ----------------------------------------------------------------- LogDebugMsg() { typeset THISMG="$*" [[ "${DEBUG}" != "" ]] && echo "
${THISMSG}
" } ### ----------------------------------------------------------------- trap_exit() { die 0 } ### ----------------------------------------------------------------- die() { typeset THISRC=$1 [ "$1"x != ""x ] && shift if [ ${THISRC} != 0 ] ; then PrintErrorPage "$*" fi [ "${TMPFILE1}"x != ""x -a -f ${TMPFILE1} ] && rm ${TMPFILE1} 1>/dev/null 2>/dev/null [ "${TMPFILE2}"x != ""x -a -f ${TMPFILE2} ] && rm ${TMPFILE2} 1>/dev/null 2>/dev/null [ "${TMPFILE3}"x != ""x -a -f ${TMPFILE3} ] && rm ${TMPFILE3} 1>/dev/null 2>/dev/null [ "${PATCH_DOWNLOAD_LOCKFILE}"x != ""x -a -f ${PATCH_DOWNLOAD_LOCKFILE} ] && rm ${PATCH_DOWNLOAD_LOCKFILE} [ "${XREF_DOWNLOAD_LOCKFILE}"x != ""x -a -f ${XREF_DOWNLOAD_LOCKFILE} ] && rm ${XREF_DOWNLOAD_LOCKFILE} exit ${THISRC} } ### ----------------------------------------------------------------- ### main trap trap_exit exit DEBUG="" PAGE_TYPE="html" exec 2>&1 __USERID=$( /usr/ucb/whoami ) PATH=$PATH:/usr/local/bin export PATH PATCH_DOWNLOAD_LOCKFILE="${LOCAL_PATCH_DIRECTORY}/.lock" XREF_DOWNLOAD_LOCKFILE="${PATCHDIAG_XREF_FILE_DIR}/.lock" TMPFILE1="/tmp/$( basename $0 )_1.$$.tmp" TMPFILE2="/tmp/$( basename $0 )_2.$$.tmp" TMPFILE3="/tmp/$( basename $0 )_3.$$.tmp" # init variables ACTION="" PATCH_ARC="" PATCH_OS="" RECOMMENDED_PATCH="" SECURITY_PATCH="" OBSOLETE_PATCH="" WITHDRAWN_PATCH="" PATCH_MUST_EXIST_LOCAL="N" FREETEXT="" NO_OF_PATCHES=0 oIFS="${IFS}" IFS="&" export IFS set -- ${QUERY_STRING} while [[ "$1" != "" ]] ; do CURKEY="${1%=*}" CURVALUE="${1#*=}" eval "${CURKEY}=\"\$CURVALUE\" " shift done IFS="${oIFS}" if [[ "${PATCH_DIRECTORY}" != "" ]] ; then PATCH_DIRECTORY="$( ConvertString "${PATCH_DIRECTORY}" )" if [ -f "${PATCH_DIRECTORY}" ] ; then LOCAL_PATCH_DIRECTORY="$( dirname ${PATCH_DIRECTORY} )" else LOCAL_PATCH_DIRECTORY="${PATCH_DIRECTORY}" fi fi # [[ "${QUERY_STRING}" != "" ]] && ACTION="TEST" if [[ "${FREETEXT}" != "" ]] ; then SEARCHSTRING="$( ConvertString "${FREETEXT}" )" # FREETEXT=$( echo "${FREETEXT}" | tr "+" " " ) # SEARCHSTRING=$( bash -c "printf '$( echo "${FREETEXT}" | sed 's/%/\\x/g' )' " ) # SEARCHSTRING=$( bash -c "printf '$( echo "${FREETEXT}" | sed 's/%/\\x/g' )' " ) fi #ACTION=PATCH_LIST #ACTION=CHECK_REQ #ACTION=GET_PATCHDIAG_XREF #ACTION=PATCH_LIST #PATCH_ARC="sparc" #PATCH_OS="9" #RECOMMENDED_PATCH="R" #SECURITY_PATCH="S" #OBSOLETE_PATCH="o" #WITHDRAWN_PATCH="b" #FREETEXT="cray" #PATCH_MUST_EXIST_LOCAL="N" case ${ACTION} in "TEST" ) PrintPageHeader echo SERVER_SOFTWARE = $SERVER_SOFTWARE echo "
" echo SERVER_NAME = $SERVER_NAME echo "
" echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE echo "
" echo SERVER_PROTOCOL = $SERVER_PROTOCOL echo "
" echo SERVER_PORT = $SERVER_PORT echo "
" echo REQUEST_METHOD = $REQUEST_METHOD echo "
" echo HTTP_ACCEPT = "$HTTP_ACCEPT" echo "
" echo PATH_INFO = "$PATH_INFO" echo "
" echo PATH_TRANSLATED = "$PATH_TRANSLATED" echo "
" echo SCRIPT_NAME = "$SCRIPT_NAME" echo "
" echo QUERY_STRING = "$QUERY_STRING" echo "
" echo REMOTE_HOST = $REMOTE_HOST echo "
" echo REMOTE_ADDR = $REMOTE_ADDR echo "
" echo REMOTE_USER = $REMOTE_USER echo "
" echo AUTH_TYPE = $AUTH_TYPE echo "
" echo CONTENT_TYPE = $CONTENT_TYPE echo "
" echo CONTENT_LENGTH = $CONTENT_LENGTH echo "
" echo "
ACTION= \"${ACTION}\" " echo "
PATCH_ARC = \"${PATCH_ARC}\" " echo "
PATCH_OS = \"${PATCH_OS}\" " echo "
RECOMMENDED_PATCH = \"${RECOMMENDED_PATCH}\" " echo "
SECURITY_PATCH = \"${SECURITY_PATCH}\" " echo "
OBSOLETE_PATCH = \"${OBSOLETE_PATCH}\" " echo "
WITHDRAWN_PATCH = \"${WITHDRAWN_PATCH}\" " echo "
PATCH_MUST_EXIST_LOCAL = \"${PATCH_MUST_EXIST_LOCAL}\" " echo "
FREETEXT= \"${FREETEXT}\" " echo "
SEARCHSTRING= \"${SEARCHSTRING}\" " PrintPageFooter ;; "INIT_PAGE" | "" ) PrintFrameSet ;; "NEWS" ) PrintNewsPage ;; "CHECK_REQ" ) CheckRequirements ;; "EMPTY_PAGE" ) PrintEmptyFrame ;; "NAVIGATION" ) Print_NavigationFrame ;; "PATCH_LIST" ) [ "${PATCH_ARC}"x = "all"x ] && PATCH_ARC="" [ "${PATCH_OS}"x = "all"x ] && PATCH_OS="" PrintPatchListFrame ;; "GET_PATCHDIAG_XREF" ) RetrievePatchDiagxref ;; "VIEW_PATCHDIAG_XREF" ) ViewPatchDiagxref ;; "DOWNLOAD_PATCH" ) DownloadPatch ;; * ) PrintErrorPage "Internal Error: Unknown action \"${ACTION}\" " ;; esac die 0