Windows 스크립트 및 지침

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

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

    Table 3-11 input.properties 매개변수

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

    월은 1월인 01에서 12월인 12까지 두 자리 숫자로 지정해야 합니다. 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.ps1을 생성합니다.
    # Skip Update PowerShell script
    
    $inputproperties = ConvertFrom-StringData(Get-Content ./input.properties -raw)
    $username="$($inputproperties.username)"
    $password="$($inputproperties.password)"
    $url="$($inputproperties.url)"
    $updatemonths="$($inputproperties.updatemonths)"
    
    $monthsarr = ("01","02","03","04","05","06","07","08","09","10","11","12")
    $global:monthsarrfromcurrent = @()
    $global:yearsarrfromcurrent = @()
    $updatemonthsarr = $updatemonths.Split(",")
    $currentyear=Get-Date -Format yy
    $currentmonth=Get-Date -Format MM
    $nextyear=[int]$currentyear+1
    
    function populateFromCurrentArrays() {
        $startposition = 0
    
        for ($i = 0; $i -le ($monthsarr.length - 1); $i++) {
            if (${currentmonth} -eq $monthsarr[$i]) {
                $startposition=$i
                break
            }
        }
    
        for ($i = 0; $i -le ($monthsarr.length - 1); $i++) {
            if (${i} -ge ${startposition}) {
                $global:monthsarrfromcurrent += $monthsarr[$i]
                $global:yearsarrfromcurrent += $currentyear
            }
        }
    
        for ($i = 0; $i -le ($monthsarr.length - 1); $i++) {
            if (${i} -lt ${startposition}) {
                $global:monthsarrfromcurrent += $monthsarr[$i]
                $global:yearsarrfromcurrent += $nextyear
            }
        }
    }
    
    function skipUpdateAdd($yearnumber, $monthnumber) {
        echo "Running: epmautomate.bat skipUpdate add version=${yearnumber}.${monthnumber} comment=`"adding skipUpdate`""
        epmautomate skipUpdate add version=${yearnumber}.${monthnumber} comment="adding skipUpdate"
    }
    
    function processSkipUpdates() {
        $addcount = 0
    
        echo "Running: epmautomate.bat login ${username} ${password} ${url}"
        epmautomate login ${username} ${password} ${url}
        echo "Running: epmautomate.bat skipUpdate remove"
        epmautomate skipUpdate remove
    
        for ($i = 0; $i -le ($global:monthsarrfromcurrent.length - 1); $i++) {
            $match = 1
    
            if (${addcount} -eq 2) {
                echo "Two skip update add calls have been made. No more will be attempted."
                break
            }
    
            for ($j = 0; $j -le ($updatemonthsarr.length - 1); $j++) {
                if ($global:monthsarrfromcurrent[$i] -eq $updatemonthsarr[$j]) {
                    $match = 0
                    break
                }
            }
    
            if (${match} -eq 1) {
                skipUpdateAdd $global:yearsarrfromcurrent[$i] $global:monthsarrfromcurrent[$i]
                $addcount += 1
            }
        }
    
        echo "Running: epmautomate.bat skipUpdate list"
        epmautomate skipUpdate list
        echo "Running: epmautomate.bat logout"
        epmautomate logout
    }
    
    function compareUpdateMonths($thismonth, $nextmonth) {
        $nextmonthorig=${nextmonth}
    
        if (${nextmonth} -lt ${thismonth}) {
            $nextmonth+=12
        }
    
        $monthdiff = $nextmonth - $thismonth
    
        if (${monthdiff} -gt 3) {
            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
        }
    }
    
    function validateUpdateMonths() {
        for ($i = 0; $i -le ($updatemonthsarr.length - 1); $i++) {
            $nextint = $i + 1
            $thisupdatemonth = $updatemonthsarr[$i]
            $thisupdatemonthint=[int]$thisupdatemonth
            $nextupdatemonth=$updatemonthsarr[$nextint]
            $nextupdatemonthint=[int]$nextupdatemonth
    
            if (${nextupdatemonth} -eq "") {
                $nextupdatemonth=$updatemonthsarr[0]
                $nextupdatemonthint=[int]$nextupdatemonth
            }
    
            compareUpdateMonths $thisupdatemonthint $nextupdatemonthint
        }
    }
    
    validateUpdateMonths
    populateFromCurrentArrays
    processSkipUpdates