# Maris Elsins / Pythian / 2013 # Source: https://github.com/MarisElsins/TOOLS/blob/master/Shell/getMOSPatch.sh # Inspired by John Piwowar's work: http://only4left.jpiwowar.com/2009/02/retrieving-oracle-patches-with-wget/ # Usage: # getMOSPatch.sh reset=yes # Use to refresh the platform and language settings # getMOSPatch.sh patch=patchnum_1[,patchnum_n]* [download=all] [regexp=...]# Use to download one or more patches. If "download=all" is set all patches will be downloaded without user interaction, you can also define regular expressen by passing regexp to filter the patch filenames. # v1.0 Initial version # v1.1 Added support for multipart patches, previously these were simply ignored. # v1.2 This version of getMOSPatch is now obsolete. Use https://github.com/MarisElsins/getMOSPatch/raw/master/getMOSPatch.jar instead # exit on the first error set -e echo echo "This version of getMOSPatch is obsolete" echo "Download getMOSPatch V2 from: https://github.com/MarisElsins/getMOSPatch/raw/master/getMOSPatch.jar" echo "Check the README for the new version here: https://github.com/MarisElsins/getMOSPatch/blob/master/README.md" echo "Read my blog post about it here: http://bit.ly/getMOSPatchV2" echo # Processing the arguments by setting the respective variables # all arguments are passed to the shell scripts in form argname=argvalue # This command sets the following variables for each argument: p_argname=argvalue for var in "$@" ; do eval "export p_${var}"; done # Did we get all the variables we need? if [ -z "$p_patch" ] && [ "$p_reset" != "yes" ] ; then echo "Not enough parameters. Usage: `basename $0` reset=yes # Use to refresh the platform and language settings `basename $0` patch=patchnum_1[,patchnum_n]* [download=all] # Use to download one or more patches. If download=all is set all patches will be downloaded without user interaction `basename $0` patch=patchnum_1[,patchnum_n]* [download=all] [readme=yes] [xml=yes] [destination=]" exit 1 fi # change into p_destination if defined, so we can run this from crontab or from other script if [ $p_destination ]; then echo "changing directory to $p_destination" [ -d $p_destination ] || mkdir -p $p_destination pushd $p_destination >/dev/null 2>&1 UNPUSHD="$?" fi # Setting some variables for the files I'll operati with PREF=`basename $0` CD=`dirname $0` CFG=${CD}/.${PREF}.cfg TMP1=${CD}/.${PREF}.tmp1 TMP2=${CD}/.${PREF}.tmp2 TMP3=${CD}/.${PREF}.tmp3 COOK=${CD}/.${PREF}.cookies # Reading the MOS user credentials. Set environment variables mosUser and mosPass if you want to skip this. [[ $mosUser ]] || read -p "Oracle Support Userid: " mosUser; [[ $mosPass ]] || read -sp "Oracle Support Password: " mosPass; echo touch ~/.wgetrc chmod 600 ~/.wgetrc perl -pi -e 'if(/^user=/){undef $_}' ~/.wgetrc perl -pi -e 'if(/^password=/){undef $_}' ~/.wgetrc echo "user=$mosUser" >> ~/.wgetrc echo "password=$mosPass" >> ~/.wgetrc set +e wget --save-cookies=$COOK --keep-session-cookies --no-check-certificate "https://updates.oracle.com/Orion/SimpleSearch/switch_to_saved_searches" -O $TMP1 -o $TMP2 --no-verbose RESULT=$? perl -pi -e 'if(/^user=/){undef $_}' ~/.wgetrc perl -pi -e 'if(/^password=/){undef $_}' ~/.wgetrc if [ ${RESULT} -ne 0 ] ; then cat $TMP2 exit 1 fi rm $TMP2 $TMP1 $TMP3 >/dev/null 2>&1 set -e # If we run the script the first time we need to collect Language and Platform settings. # This part also executes if reset=yes # This part fetches the simple search form from mos and parses all Platform and Language codes if [ ! -f $CFG ] || [ "$p_reset" == "yes" ] ; then echo; echo Getting the Platform/Language list wget --no-check-certificate --load-cookies=$COOK "https://updates.oracle.com/Orion/SavedSearches/switch_to_simple" -O $TMP1 -q echo "Available Platforms and Languages:" grep -A999 "