Issues deploying macOS software updates to Catalina.

AJPinto
Honored Contributor II

Good morning all,
I am having some issues with the script we use to run software updates for macOS with Catalina. It is still working fine for Mojave and earlier but for Catalina it appears to just keep rebooting the Mac. From what I can tell it is not actually installing the updates or updating the plist correctly so it is not cleared from the list and the policy goes down again causing our Catalina devices to reboot about every 20 minutes so long as they are scoped for the policy. I am not seeing what may be causing it and was wondering you guys see something I am not, I am also a relatively new JAMF admin so it is entirely possible I am looking over something :).

#!/bin/bash
#*=============================================================================
#* Script Name: 
#* Created:
#* Author: 
#*=============================================================================
#* Purpose: Deploy new policy changes and updates
#*=============================================================================

#*=============================================================================
#* GLOBAL VARIABLES
#*=============================================================================
DIV1='####################################################################'
DIV2='--------------------------------------------------------------------'
DIV3='....................................................................'
ActiveUser=`ls -l /dev/console 
    | awk '{ print $3 }' 
    | tr "[a-z]" "[A-Z]"`
ActiveUserRealName=`dscl . -read /Users/$ActiveUser 
    | grep RealName: 
    | cut -c11-`
if [[ -z $ActiveUserRealName ]]; then
    ActiveUserRealName=`dscl . -read /Users/$ActiveUser 
    | awk '/^RealName:/,/^RecordName:/' 
    |sed -n 2p | cut -c 2-`
fi
nag="/Library/Regions/Tools/Nag/nag"
scriptPath=${0}
scriptParent=${0%/*}
scriptFile=${0##*/}
scriptName=${scriptFile%.*}
logName="$scriptName"
logFile="$logName.log"
logFolder="/Library/Logs/RGBK"
logPath="$logFolder/$logFile"
#*=============================================================================
#* FUNCTIONS
#*=============================================================================
function writeLog(){
     NOW="$(date +"%Y-%m-%d %H:%M:%S")"
     echo "$NOW": "$1" 2>&1 | tee -a $logPath
}
function startScript {
   ## Create log file
   mkdir -pv $logFolder; touch $logFile
   # Start script
   writeLog "$DIV1$DIV1"
   writeLog $DIV1
   # Computer info
   if [[ "$ActiveUserRealName" == "$ActiveUser" ]]
   then activeUserStart="$ActiveUserRealName (Local Admin)"
   else activeUserStart="$ActiveUserRealName ($ActiveUser)"
   fi
   writeLog "Active User: $activeUserStart"
   writeLog "Computer Name: $(sudo /usr/sbin/scutil --get ComputerName)"
   writeLog "OS Version: macOS $(sw_vers -productVersion)"
   writeLog $DIV2
   writeLog "Starting script $scriptName"
   writeLog "Log path: $logPath"
   writeLog $DIV1
}
#*=============================================================================
#* SCRIPT BODY
#*=============================================================================
startScript

#-----------------------------------------------------------------------------#
# PLIST CONFIGURATION
#-----------------------------------------------------------------------------#
# By the end of the update deployment, the mpd plist should have the keys
# bellow. Make sure to sudo when writing to the plist.
#       install.date (date)         computer.name (string)
#       active.user (string)            mpd.version (string)
serialNumber=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | tr '[:upper:]' '[:lower:]')
mpd_version="2001"
plistLocation="/Library/Regions/Preferences"
plistName="com.regions.mpd.plist"

# Make destination folder
mkdir $plistLocation

# Write date to plist
sudo defaults write "$plistLocation/$plistName" install.date -date "$(date)"
sudo defaults write "$plistLocation/$plistName" computer.name -string "$serialNumber"
sudo defaults write "$plistLocation/$plistName" active.user -string "$ActiveUserRealName ($ActiveUser)"
#-----------------------------------------------------------------------------#
# Install nag
if [ ! -f "$nag" ] 
then 
    writeLog "Installing nag tool"
    sudo jamf policy -event install_nag
    writeLog $DIV2
fi
#-----------------------------------------------------------------------------#
# RFBIA Enforcement
writeLog "Calling RFBIA enforcement policy"
sudo jamf policy -event enforce_RFBIA
writeLog $DIV2
#-----------------------------------------------------------------------------#
# macOS Software Updates
softwareupdate --install --all
#-----------------------------------------------------------------------------#
# Update MPD Plist
writeLog $DIV1
sudo defaults write "$plistLocation/$plistName" mpd.version -string "$mpd_version"
#*=============================================================================
#* END OF SCRIPT
#*=============================================================================
2 REPLIES 2

donmontalvo
Esteemed Contributor III

Its the bold font you’re using in your script. :)

Sect your script and use the “>_” button.

--
https://donmontalvo.com

AJPinto
Honored Contributor II

Thank for pointing out that newbie mistake :), I just fixed the post so the script should show right now.

As far as the bold text, it should all be commented out. Shouldn't commented text be ignored when the script is ran? VS code is not showing any formatting but I will try to strip any text formatting and see where that gets me. Thank you!