JSS-Scripts icon indicating copy to clipboard operation
JSS-Scripts copied to clipboard

OSUpdateNotifier: checkAttemptToQuit() function will not quit if input value is empty

Open phu-ngo opened this issue 3 years ago • 0 comments

in some case the jamfhelper killed by terminal or Activity Monitor it will not return 239 error code and return empty intend

old code

checkAttemptToQuit(){
    Value="${1}"
    
    # Jamf Helper was exited without making a choice
    if [[ "$Value" == "239" ]]; then
        echo "Jamf Helper was exited without making a choice."
        "$jamf" policy -event "$CustomTriggerNameDeprecationPolicy" &
        exit 0
    fi
}

fix

checkAttemptToQuit(){
    Value="${1}"
    
    # Jamf Helper was exited without making a choice
    # pngo 12/31/21: include empty return code
    # The 239 return value is defaults when user quit the jamfhelper (Command+Q) if user kill it using kill [pid] command it will return empty
    if [[ "$Value" == "239" ]] || [[ -z "$Value" ]]; then
        echo "Jamf Helper was exited without making a choice."
        "$jamf" policy -event "$CustomTriggerNameDeprecationPolicy" &
        exit 0
    fi
}

phu-ngo avatar Jan 10 '22 04:01 phu-ngo