UNIX/Linux 스크립트 및 지침

이 섹션의 스크립트를 복사하여 input.propertiesskip_update.sh를 생성합니다.

  1. 다음 스크립트를 복사하여 input.properties를 생성합니다.
    javahome=JAVA_HOME
    epmautomatescript=EPM_AUTOMATE_LOCATION
    username=exampleAdmin
    password=examplePassword.epw
    url=exampleURL
    updatemonths=02,05,08,11
    
  2. 매개변수 값을 지정하여 input.properties를 업데이트합니다.

    Table 3-12 input.properties 매개변수

    매개변수 설명
    javahome JAVA_HOME 위치입니다.
    epmautomatescript EPM Automate 실행 파일의 절대 경로(epmautomate.sh)입니다.
    username 서비스 관리자.의 사용자 이름
    password 서비스 관리자의 비밀번호 또는 암호화된 비밀번호 파일의 이름 및 위치입니다.
    url 월별 이외의 업데이트 주기를 설정할 환경의 URL입니다.
    updatemonths Oracle Enterprise Performance Management Cloud 업데이트가 url 매개변수로 확인된 환경에 적용되어야 하는 월에 대한 쉼표로 구분된 목록입니다. updatemonths=02,05,08,11을 예로 들 수 있습니다.

    월은 두 자리 숫자로 지정해야 합니다. 1월에서 9월 앞에는 0이 포함됩니다. 스크립트는 updatemonths 매개변수 값에 포함되지 않은 월에 skipUpdate 명령을 실행하려고 시도합니다. 예를 들어 updatemonths=02,05,08,11을 지정하는 경우 스크립트는 1월, 3월, 4월, 6월, 7월, 9월, 10월, 12월에 업데이트 건너뛰기 플래그를 설정하여 2월, 5월, 8월, 11월에만 업데이트가 수행되도록 합니다.

  3. 다음 스크립트를 복사하여 skip_updates.sh를 생성합니다.
    #!/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