2 Replies Latest reply on Apr 25, 2011 9:22 PM by Jim Campbell

    Installing a software package based off of OS/architecture

      I have created a BLPackage that contains multiple application versions. I would like to create a NSH script that can deploy the appropriate software based on OS version and architecture, i.e. Windows 2008 and 64bit or Windows 2003 and 32bit. Is there an easy way to determine this through a NSH script and kick off the appropriate install or should I just create separate BLPackages and install jobs for each OS/architecture?

        • 1. Installing a software package based off of OS/architecture

          I personally have done it with different deploy packages for each platform (x86/x64) and have a NSH/VBScript that is executed on the remote windows servers.

           

          Here is a baseline for what I have done... where the Depot Packages have ??TARGET.SYSTEMROOT??\Temp\<PackageName> as their staging folder.

           

          Hope this points you in the right direction.  It may be a bit more complex than what you need but is taken from work I did for deploying platform based packages; soft linked in the depot.

           

          #!/bin/nsh
          ##
          ## Created: 03/03/2011 01:12:18 PM
          ## Revision: 1
          ##

          #
          # Passed in parameters from the job
          #
          DJTEMPPATH="$1"
          DJPACKAGEPATH="$2"
          PKGX86="$3"
          PKGX64="$4"

          echo "Deploy Job Temp Path = " ${DJTEMPPATH}
          echo "Deploy Job Package Path = " ${DJPACKAGEPATH}
          echo "x86 DEPOT Package = " ${PKGX86}
          echo "x64 DEPOT Package = " ${PKGX64}

          ##
          ## Start up BladeLogic CLI (Performance Mode)
          ##
          blcli_setjvmoption -Xmx256m
          blcli_setoption roleName <yourRole>
          blcli_setoption serviceProfileName <yourProfile>
          blcli_connect
          #blcli_printjvmdetails

          ##
          ## Get Server Name
          ##
          SERVERNAME=$(hostname | tr "[:lower:]" "[:upper:]")
          echo "SERVERNAME = " ${SERVERNAME}

          ##
          ## Get Windows Installation Folder (<DRIVE>:\Windows)
          ##
          blcli_execute Server printPropertyValue ${SERVERNAME} SYSTEMROOT
          blcli_storeenv PROPSYSROOT
          echo "" # because storeenv doesn't add a newline
          PROPSYSROOT2=$(echo ${PROPSYSROOT} | awk 'BEGIN{FS="/";OFS="\\"}{$2=$2":";print substr($0,2)}')
          PROPSYSROOT3=$(echo ${PROPSYSROOT} | cut -c 1-2)
          PROPSYSROOT4=$(echo ${PROPSYSROOT} | cut -c 2)
          PROPSYSROOT4="$PROPSYSROOT4:"

          ##
          ## Determine Server OS Platform (x86, x86_64)
          ##
          blcli_execute Server printPropertyValue ${SERVERNAME} OS_PLATFORM
          blcli_storeenv PROPSYSARCH
          echo "" # because storeenv doesn't add a newline

          ##
          ## Set Deploy Package based on OS Platform (x86, x86_64)
          ##
          if test "${PROPSYSARCH}" = "x86_64"
          then
          DJPACKAGEFILE="${PKGX64}"
          else
          DJPACKAGEFILE="${PKGX86}"
          fi
          echo "Deploy Job Package Name = " ${DJPACKAGEFILE}
          echo " "

          ##
          ## Create and Execute (Temporary) DEPLOY JOB
          ##
          SIMULATE=true
          COMMIT=true
          INDIRECT=false
          DEPLOYOPTS="${SIMULATE} ${COMMIT} ${INDIRECT}"
          echo "Checking for a previous Temp Deploy Job Package"
          blcli_execute DeployJob deleteJobByGroupAndName "${DJTEMPPATH}" "${DJPACKAGEFILE} ${SERVERNAME}"
          if test $? -ne 0
          then
          echo "No Previous Version Exists"
          else
          echo "Removed Previous Version - ${DJPACKAGEFILE} ${SERVERNAME}"
          fi
          echo "Retrieving Deploy Package Key"
          blcli_execute BlPackage getDBKeyByGroupAndName "${DJPACKAGEPATH}" "${DJPACKAGEFILE}"
          blcli_storeenv PACKAGEKEY
          echo " " # because storeenv doesn't add a newline
          blcli_execute JobGroup groupNameToId "${DJTEMPPATH}"
          blcli_storeenv GROUPID
          echo " " # because storeenv doesn't add a newline
          echo "Creating Temp Deploy Job"
          blcli_execute DeployJob createDeployJob "${DJPACKAGEFILE} ${SERVERNAME}" "${GROUPID}" "${PACKAGEKEY}" "${SERVERNAME}" ${DEPLOYOPTS}
          blcli_storeenv DEPLOYJOBKEY
          echo " " # because storeenv doesn't add a newline
          echo "Executing Temp Deploy Job"
          blcli_execute DeployJob executeJobAndWait ${DEPLOYJOBKEY}
          blcli_storeenv DEPLOYJOBRUNKEY
          echo " " # because storeenv doesn't add a newline

          ##
          ## Setup Command Line for Unattended Install of the client
          ##
          cd "//${SERVERNAME}${PROPSYSROOT}/Temp/<Package>"
          echo -n "Current Working Directory = "
          pwd
          echo " "
          echo "Executing Your Installer"
          echo " ******************************************************** "
          nexec <yourSteps>
          echo " ******************************************************** "

          ##
          ## Remove Temporary Install Files on the Target and BL Deploy Job
          ##
          cd "//${SERVERNAME}${PROPSYSROOT}/Temp"
          rm -r "${PROPSYSROOT}/Temp/<Package>"
          blcli_execute DeployJob deleteJobByGroupAndName "${DJTEMPPATH}" "${DJPACKAGEFILE} ${SERVERNAME}" 
          echo "" # because deleteJobByGroupAndName returns VOID and doesn't add a newline
          if test $? -ne 0
          then
          echo "No Previous Version Exists"
          else
          echo "Removed Temp Deploy Job Package - ${DJPACKAGEFILE} ${SERVERNAME}"
          fi

          ##
          ## Shutdown CLI Mode
          ##
          blcli_disconnect

          • 2. Installing a software package based off of OS/architecture
            Jim Campbell

            If you already have BLPackages you can do this pretty easily with Compliance remediation as well.  Just have a compliance rule that looks like

             

            ??TARGET.OS_VERSION?? != x86_64

            OR
            ??TARGET.OS_VERSION?? is not one of '2008','2008 R2'

             

            with the autoremediation package for 2008x64.  Then you can just have autoremediation rules for each combination of OS/archictecture and run the compliance job against all servers.

             

            The only annoying thing is that it has to be a BLPackage that is used for auto remediation rather than any type of job.