MarisElsins / getMOSPatch

getMOSPatch V2 - Tool that helps downloading patches from My Oracle Support
58 stars 17 forks source link

Feature request: Resetting platform and language code by querying a database #23

Closed sniperkitten closed 3 years ago

sniperkitten commented 3 years ago

Hi Maris I like getMOSPatch very much, thank you! I use it to download patches for several EBS environments with many languages. So it's a tedious task to configure getMOSPatch.sh every time. Of course I could create separate configuration files for every environment, but we add new languages pretty often lately. Wouldn't it be nice to add possibility to connect to a database to pull a platform and language list from there?

Here's the prototype below written for .sh version (Which I know is desupported, but I can code only in bash):

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 "<select name=plat_lang" $TMP1 | grep "^<option"| grep -v "\-\-\-" | awk -F "[\">]" '{print $2" - "$4}' > $TMP2
  cat $TMP2

  #If a database connect descriptor is provided, using it to obtain information about platform and languages from the database
  if [ ! -z "$p_connect_descriptor" ]; then
    PlatLangCodes=`sqlplus -s apps/$APPS_PWD@$p_connect_descriptor <<EOF
    set pagesize 0
    set feedback off
    set heading off
    set echo off
    set linesize 32767
    set long 10000
    select fn.platform_code||'P' platform_and_language_code from fnd_nodes fn where fn.support_admin='Y'
    union all
    select fl.language_id||'L' platform_and_language_code from fnd_languages fl where fl.installed_flag<>'D';
    exit
EOF
`
  > $CFG
  for PLATLANG in $PlatLangCodes
  do
    grep "^$PLATLANG " $TMP2 | sed "s/ - /;/g" >> $CFG
  done

  else
    read -p "Comma-delimited list of required platform and language codes: " PlatLangCodes;
    > $CFG
    for PLATLANG in $(echo $PlatLangCodes | sed "s/,/ /g" | xargs -n 1 echo )
    do
      grep "^$PLATLANG " $TMP2 | sed "s/ - /;/g" >> $CFG
    done
  fi
  echo Configuration saved
  rm $TMP1 $TMP2 >/dev/null 2>&1
fi

Regards, Alex

MarisElsins commented 3 years ago

Hi, Thank you for the suggestion. I will not add this feature as I want to keep the utility a lean as possible, and this feature would be useful to Apps DBAs only. But, you can use the code you wrote to populate the .getMOSPatch.cfg file with the platforms/languages you require, before launching the getMOSPatch without passing the "platform" parameter. This way, the platforms list will be read from the *.cfg file.

Maris