Catalog Downloader and Update Wrapper Script

This script automates the running of offline downloaders and the running of the Catalog Update Jobs.  As of 8.2, the Catalog Update Jobs
are not currently in the Jobs workspace and they are difficult to manage because it involves digging to each catalog.  This creates
NSH Script Jobs that can be put in a Batch Job and otherwise more easily handled.

For the downloadRepo mode, you are required to upload the Offline Patch Downloader to the Depot as a Depot File


There are three (sort of four) modes of this script and they are detailed below:

General Options
  -d   <debug level>  Debug Log level output, 0-5
  -O  <notify email>   Email address to send the downloader log or Catalog Update Job notification
  -m  <scriptMode>  downloadRepo, updateCatalog, installScript
  -I  <createJob>   create a NSH Script Job instead of running the download or update, true/false

ScriptMode: downloadRepo
  This mode will download the payloads from the vendor site onto the patch helper system.  The arguments should trainslate pretty clearly
  to the options required in the downloader XML files...

  -t  <targetOS>   OS type of the download: OEL, SUSE, RHEL, Windows, Solaris
  -R <retries>   Integer - number of retries for the downloader, default is 10
-T  <timeout>   Integer - timeout for the download operation, default is 180000
-P  <parallelThreads> Integer - parallel threads for downloader execution, default is 5
  -h <repoHost>   Hostname of the system holding the Patch Repository payloads
-r  <repoLocation>  Unix style path to the repository location on the repo host
-s <downloadOS>  OS tag for the downloader, used for Linux and Solaris, eg RHEL5
-a <downloadArch>  Arch tag for the downloader, used for Linux and Solaris, eg x86_64
-u  <downloadUser>  Username for Vendor patch site login, used for RHEL, SUSE and Solaris
-p  <downloadPassword> Password for the Vendor patch site login, used for RHEL, SUSE and Solaris
-c <downloadChannel> Channel name of the patches to download.  Used for Linux and Windows
-y  <yummifyRepo>  Run a createrepo after the download, this can be useful for Linux repos that are missing rpms.  true/false

  Usage: OEL
   usage -m downloadRepo -l <downloaderLocation> -r <repoLocation> -h <repoHost> -t OEL -s OEL5 -a i386 -c ol5_i386_base
  Usage: RHEL
   usage -m downloadRepo -l <downloaderLocation> -r <repoLocation> -h <repoHost> -t RHEL -s RHEL5 -a x86 -c rhel-server-5-i386
  Usage: SUSE
  usage -m downloadRepo -l <downloaderLocation> -r <repoLocation> -h <repoHost> -t SUSE -u UC***** -p ***** -a x86 -s SLES11 -c 'https://nu.novell.com/repo//SLES11-Updates/sle-11-i586/rpm/'
  Usage: Windows
      usage -m downloadRepo -l <downloaderLocation> -r <repoLocation> -h <repoHost> -t Windows -c ALL
  Usage: Solaris
      usage -m downloadRepo -l <downloaderLocation> -r <repoLocation> -h <repoHost> -t Solaris -s 10 -a sparc -u foo@foo.com -p *****

ScriptMode: updateCatalog
  This mode will run the catalog update job for the targeted catalog and can be included in Batch Jobs and scheduled more easily

-t <targetOS>   OS type of the catalog to update: OEL, SUSE, RHEL, Windows, Solaris
-C <catalogPath>  Path to the Catalog to update
-x <metaLocation>  NSH Path to the directory containing the patch meta files (Shavlik XML or patchdiag.xref), for Windows and Solaris
-h <repoHost>   Hostname of the system holding the Patch Repository payloads
-f  <depotFolder>  Depot Folder containing the Depot Files of the metadata used in the offline catalog
-j <sendNotify>  Send a notification when the Catalog Update Job starts and the result, true/false
-o  <removeObsoletes> Remove obsolete patches after the update job finishes, true/false

    Usage: Linux
  usage -m updateCatalog -t RHEL -C "/Some Path/To/Catalog" -y true -o true -h server1
  Usage: Windows/Solaris
  usage -m updateCatalog -t Solaris -C "/Some Path/To/Catalog" -x "/tmp/Windows" -f "/Workspace/Catalogs" -h server1

ScriptMode: installScript
Creates a NSHScript Object in the Depot
  Usage: usage -m installScript

createJob - to create a job run the script in updateCatalog or downloadRepo and add the -I true and a job will be created in the Jobs
workspace with all the optons you have specified, then you can run the job
  Usage: usage -m updateCatalog -t RHEL -C "/Some Path/To/Catalog" -y true -o true -h server1  -I true