Wednesday, 4 January 2017

EBS Applications Patch Download Script - Wget

Script Usage:
Enter "username" and "passsword" in script, refer readme url for "ARU"

sh wget.sh <patch_name> <ARU_number>
sh wget.sh p17204589_12.2.0_R12_GENERIC.zip 16610006

 Script:
#!/bin/sh

export LANG=C

# SSO username and password
SSO_USERNAME=

SSO_PASSWORD=
PATCH_NAME=$1
ARU_NUM=$2

WGET=/usr/bin/wget
COOKIE_FILE=/tmp/$$.cookies
LOGDIR=.
LOGFILE=$LOGDIR/wgetlog-`date +%m-%d-%y-%H:%M`.log
OUTPUT_DIR=.

if [ "$SSO_PASSWORD " = " " ]
then
 echo "Please edit script and set SSO_PASSWORD"
 exit
fi

SSO_RESPONSE=`$WGET --user-agent="Mozilla/5.0" https://updates.oracle.com/Orion/Services/download 2>&1|grep Location`
SSO_TOKEN=`echo $SSO_RESPONSE| cut -d '=' -f 2|cut -d ' ' -f 1`
SSO_SERVER=`echo $SSO_RESPONSE| cut -d ' ' -f 2|cut -d 'p' -f 1,2`
SSO_AUTH_URL=sso/auth
AUTH_DATA="ssousername=$SSO_USERNAME&password=$SSO_PASSWORD&site2pstoretoken=$SSO_TOKEN"
$WGET --user-agent="Mozilla/5.0" --secure-protocol=auto --post-data $AUTH_DATA --save-cookies=$COOKIE_FILE --keep-session-cookies $SSO_SERVER$SSO_AUTH_URL -O sso.out >> $LOGFILE 2>&1
rm -f sso.out
$WGET  --user-agent="Mozilla/5.0"  --load-cookies=$COOKIE_FILE --save-cookies=$COOKIE_FILE --keep-session-cookies "https://updates.oracle.com/Orion/Services/download/"$PATCH_NAME"?aru="$ARU_NUM"&patch_file="$PATCH_NAME -O $OUTPUT_DIR/$PATCH_NAME   >> $LOGFILE 2>&1

# Cleanup
rm -f $COOKIE_FILE

No comments:

Post a Comment