Skript und Anweisungen für UNIX/Linux

Erstellen Sie input.properties und skip_update.sh, indem Sie die Skripte in diesem Abschnitt kopieren.

  1. Erstellen Sie input.properties, indem Sie das folgende Skript kopieren:
    javahome=JAVA_HOME
    epmautomatescript=EPM_AUTOMATE_LOCATION
    username=exampleAdmin
    password=examplePassword.epw
    url=exampleURL
    updatemonths=02,05,08,11
    
  2. Aktualisieren Sie input.properties, indem Sie Parameterwerte festlegen.

    Table 3-12 Parameter für "input.properties"

    Parameter Beschreibung
    javahome Verzeichnis JAVA_HOME.
    epmautomatescript Absoluter Pfad der ausführbaren Datei für EPM Automate (epmautomate.sh).
    username Benutzername eines Serviceadministrators.
    password Kennwort des Serviceadministrators oder Name und Speicherort der verschlüsselten Kennwortdatei.
    url URL der Umgebung, in der Sie das nicht monatliche Update-Intervall festlegen möchten.
    updatemonths Eine durch Komma getrennte Liste der Monate, in denen Oracle Enterprise Performance Management Cloud-Updates auf die vom Parameter url angegebene Umgebung angewendet werden sollen. Beispiel: updatemonths=02,05,08,11.

    Monate müssen mit zwei Ziffern angegeben werden. Stellen Sie für die Monate Januar bis September eine Null voran. Das Skript versucht, den Befehl skipUpdate für die Monate auszuführen, die nicht im Parameterwert updatemonths enthalten sind. Beispiel: Wenn Sie updatemonths=02,05,08,11 festlegen, versucht das Skript, Kennzeichen zum Überspringen von Updates für Januar, März, April, Juni, Juli, September, Oktober und Dezember festzulegen, damit Updates nur im Februar, Mai, August und November durchgeführt werden.

  3. Erstellen Sie skip_updates.sh, indem Sie das folgende Skript kopieren:
    #!/bin/sh
    
    . ./input.properties
    export JAVA_HOME=${javahome}
    
    declare -a monthsarr=(01 02 03 04 05 06 07 08 09 10 11 12)
    declare -a monthsarrfromcurrent
    declare -a yearsarrfromcurrent
    updatemonthsarr=( $(echo "${updatemonths}" | sed 's/,/ /g') ) 
    currentyear=$(date +%y)
    nextyear=$((currentyear+1))
    currentmonth=$(date +%m)
    
    populateFromCurrentArrays() {
        for i in ${!monthsarr[@]}
        do
            if [[ "${currentmonth}" == "${monthsarr[$i]}" ]]
            then 
                startposition=$i
                break
            fi
        done
    
        for i in ${!monthsarr[@]}
        do
            if [[ ${i} -ge ${startposition} ]]
            then 
                monthsarrfromcurrent=("${monthsarrfromcurrent[@]}" "${monthsarr[$i]}")
                yearsarrfromcurrent=("${yearsarrfromcurrent[@]}" "${currentyear}")
            fi
        done
    
        for i in ${!monthsarr[@]}
        do
            if [[ ${i} -lt ${startposition} ]]
            then 
                monthsarrfromcurrent=("${monthsarrfromcurrent[@]}" "${monthsarr[$i]}")
                yearsarrfromcurrent=("${yearsarrfromcurrent[@]}" "${nextyear}")
            fi
        done
    }
    
    skipUpdateAdd() {
        local yearnumber="$1"
        local monthnumber="$2"
    
        echo "Running: ${epmautomatescript} skipUpdate add version=${yearnumber}.${monthnumber} comment=\"adding skipUpdate\""
        ${epmautomatescript} skipUpdate add version=${yearnumber}.${monthnumber} comment="adding skipUpdate"
    }
    
    processSkipUpdates() {
        local addcount=0
    
        echo "Running: ${epmautomatescript} login ${username} ${password} ${url}"
        ${epmautomatescript} login ${username} ${password} ${url}
        echo "Running: ${epmautomatescript} skipUpdate remove"
        ${epmautomatescript} skipUpdate remove
    
        for i in ${!monthsarrfromcurrent[@]}
        do
            local match=1
    
            if [[ ${addcount} -eq 2 ]]
            then
                echo "Two skip update add calls have been made. No more will be attempted."
                break
            fi
    
            for j in ${!updatemonthsarr[@]}
            do
                if [[ "${monthsarrfromcurrent[$i]}" == "${updatemonthsarr[$j]}" ]]
                then
                    match=0
                    break
                fi
            done
    
            if [[ ${match} -eq 1 ]]
            then 
                skipUpdateAdd ${yearsarrfromcurrent[$i]} "${monthsarrfromcurrent[$i]}"
                addcount=$((addcount+1))
            fi
        done
    
        echo "Running: ${epmautomatescript} skipUpdate list"
        ${epmautomatescript} skipUpdate list
        echo "Running: ${epmautomatescript} logout"
        ${epmautomatescript} logout
    }
    
    compareUpdateMonths() {
        local thismonth=$1
        local nextmonth=$2
        local nextmonthorig=${nextmonth}
     
        if [[ ${nextmonth} -lt ${thismonth} ]]
        then
            nextmonth=$((nextmonth+12))
        fi
    
        monthdiff=$((nextmonth-thismonth))
    
        if [[ ${monthdiff} -gt 3 ]]
        then 
            echo "There are more than 2 months skipped from month ${thismonth} to month ${nextmonthorig}. Please correct updatemonths in input.properties so that there are not more than two months skipped between each update month. Exiting."
            exit 1
        fi
    }
    
    validateUpdateMonths() {
        for i in ${!updatemonthsarr[@]}
        do
            nextint=$((i+1))
            thisupdatemonth="${updatemonthsarr[$i]}"
            thisupdatemonthint=${thisupdatemonth#0}
            nextupdatemonth="${updatemonthsarr[$nextint]}"
            nextupdatemonthint=${nextupdatemonth#0}
    
            if [[ ${nextupdatemonth} == "" ]]
            then 
                nextupdatemonth="${updatemonthsarr[0]}"
                nextupdatemonthint=${nextupdatemonth#0}
            fi
    
            compareUpdateMonths ${thisupdatemonthint} ${nextupdatemonthint}
        done
    }
    
    validateUpdateMonths
    populateFromCurrentArrays
    processSkipUpdates