Script per UNIX/Linux e istruzioni

Creare input.properties e skip_update.sh copiando gli script di questa sezione.

  1. Creare il file input.properties copiando lo script riportato di seguito.
    javahome=JAVA_HOME
    epmautomatescript=EPM_AUTOMATE_LOCATION
    username=exampleAdmin
    password=examplePassword.epw
    url=exampleURL
    updatemonths=02,05,08,11
    
  2. Aggiornare il file input.properties specificando i valori dei parametri.

    Table 3-12 Parametri di input.properties

    Parametro Descrizione
    javahome Posizione di JAVA_HOME.
    epmautomatescript Percorso assoluto dell'eseguibile di EPM Automate (epmautomate.sh).
    username Nome utente di un amministratore del servizio.
    password Password dell'Amministratore servizi o nome e posizione del password file cifrato.
    url URL dell'ambiente in cui si desidera impostare la cadenza di aggiornamento non mensile.
    updatemonths Applicare un elenco separato da virgole con i mesi in cui viene aggiornato Oracle Enterprise Performance Management Cloud all'ambiente identificato dal parametro url. Ad esempio, updatemonths=02,05,08,11.

    I mesi devono essere specificati con due cifre. Anteporre uno zero per i mesi da gennaio a settembre. Lo script tenta di eseguire il comando skipUpdate per i mesi non inclusi nel valore del parametro updatemonths. Se ad esempio si specifica updatemonths=02,05,08,11, lo script tenta di impostare i flag per saltare gli aggiornamenti per gennaio, marzo, aprile, giugno, luglio, settembre, ottobre e dicembre in modo che gli aggiornamenti vengano eseguiti solo a febbraio, maggio, agosto e novembre.

  3. Creare skip_updates.sh copiando lo script riportato di seguito.
    #!/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