In case machine are updating, when script running and require refreshSUL, original function will kickstart the softwareupdated service it also will stop all current update process, we need add another function to check if there no update going on before kickstart the service
# pngo 1/5/22 include check UpdateBrainService process, to avoid restart softwareupdated when user are updating
function checkingUpdateProcess(){
if ps aux | grep -e com.apple.MobileSoftwareUpdate.UpdateBrainService$ >/dev/null; then
debug "com.apple.MobileSoftwareUpdate.UpdateBrainService is running, potental Update in process, exit"
exit 0
fi
}
include the function on on top of current refreshSoftwareUpdateList()
refreshSoftwareUpdateList(){
debug "Refresh Software Update list"
# check update process, make sure there not update running
checkingUpdateProcess
........
}