Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################
- -->> ABOUT
- #######################
- (*
- Phil Stokes -- 2017
- applehelpwriter.com
- sqwarq.com
- *)
- #######################
- -->> DESCRIPTION
- #######################
- (*
- View version and modification times of background system and security updates provided by Apple.
- *)
- #######################
- -->> USAGE
- #######################
- (*
- The script should return usable results on 10.9 and later.
- Behaviour on earlier systems is undocumented.
- *)
- ##########################################
- # Variables
- ##########################################
- set updateMarker to " *"
- set saveLocation to "~/Library/Preferences/com.appleseedCriticalUpdates.txt"
- set lastUpdate to {}
- set thisDate to {}
- set hasBeenUpdated to ""
- set TimeStrings to {"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist", "/private/var/db/gkopaque.bundle/Contents/version.plist", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist", "/System/Library/CoreServices/MRT.app/Contents/version.plist", "'/System/Library/Intelligent Suggestions/Assets.suggestionsassets/Contents/version.plist'", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version.plist", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/version.plist", "/usr/share/kdrl.bundle/info.plist"}
- set VersionStrings to {"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist Version", "/private/var/db/gkopaque.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/CoreServices/MRT.app/Contents/version CFBundleShortVersionString", "/System/Library/Intelligent\\ Suggestions/Assets.suggestionsassets/Contents/version.plist CFBundleShortVersionString", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version CFBundleShortVersionString", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/info SUVersionString", "/usr/share/kdrl.bundle/info CFBundleVersion"}
- set theComponents to {(localized string "XProtect"), (localized string "Gatekeeper"), (localized string "SIP"), (localized string "Malware Removal Tool"), (localized string "Core Suggestions"), (localized string "Incompatible Kexts"), (localized string "Chinese Word List"), (localized string "Core LSKD (kdrl)")}
- set theTabSpaces to ""
- --set _multiTabs to tab & tab & tab & tab
- set _multiTabs to getTabs(localized string "Component" & tab)
- set displayString to (localized string "Component") & _multiTabs & (localized string "Version") & tab & (localized string "Updated") & tab & tab & (localized string "Time") & return & "_________________________________________________" & return & return
- ##########################################
- # Handlers
- ##########################################
- # calculate the number of tabs required for the display dialog
- on getTabs(aWord)
- if aWord contains "Kexts" then
- return tab
- else
- set n to round (20 - (length of aWord)) / 4
- if n is less than 0 then set n to 1
- if length of aWord is 10 then set n to 2
- set this_tab to tab
- repeat n times
- set this_tab to this_tab & tab
- end repeat
- return this_tab
- end if
- end getTabs
- #get the last change date
- on getUpdatedDate(aFile)
- set d to do shell script "stat -f \"%Sc\" -t \"%m/%d/%Y %H:%M\" " & aFile
- set end of my thisDate to d
- return d
- end getUpdatedDate
- #compare the dates to see if there's been a change
- on checkLastUpdate(aDateString, anIndex)
- set n to text 1 thru 10 of aDateString
- set o to text 1 thru 10 of my (item anIndex of lastUpdate)
- if (n is equal to o) then
- return ""
- else
- return my updateMarker
- end if
- end checkLastUpdate
- ##########################################
- # Commands
- ##########################################
- # read the dates into our script from the last run
- set oldTIDS to AppleScript's text item delimiters
- set AppleScript's text item delimiters to ","
- try
- set s to (do shell script "cat " & saveLocation)
- set lastUpdate to text items of s
- end try
- set AppleScript's text item delimiters to oldTIDS
- # this is the workhorse, getting all the data for each component
- repeat with i from 1 to number of items in theComponents
- try
- set component_item to item i of theComponents
- set version_item to item i of VersionStrings
- set time_item to item i of TimeStrings
- set theTabSpaces to getTabs(component_item)
- set updatedDate to getUpdatedDate(time_item)
- # check if we had some saved dates from a previous run
- #and if so, check them against the current dates
- if (count of (lastUpdate as list)) = (count of theComponents) then
- set my hasBeenUpdated to checkLastUpdate(updatedDate, i)
- end if
- # organise the display string
- set v to (do shell script "defaults read " & version_item)
- if component_item contains "Kexts" and (text 1 of v is "1") then
- set v to v
- else if length of v < 4 or (length of v < 6 and v contains ".") then
- set v to v & tab
- end if
- set displayString to displayString & component_item & theTabSpaces & v & tab & updatedDate & my hasBeenUpdated & return
- set my hasBeenUpdated to ""
- end try
- end repeat
- #write out current dates to file
- set writeData to ""
- repeat with i from 1 to number of items in thisDate
- set this_item to item i of thisDate
- if length of writeData is 0 then
- set writeData to this_item
- else
- set writeData to writeData & "," & this_item
- end if
- end repeat
- do shell script "echo " & writeData & "> " & saveLocation
- # finally, get the OS version and build
- set theSysInfo to (do shell script "sw_vers")
- set sysString to paragraph 2 of theSysInfo & return & paragraph 3 of theSysInfo
- set displayString to displayString & return & sysString
- # and...
- set _close to localized string "Close"
- set _title to localized string "Critical Updates (Legacy Vers 1.3.3)"
- display dialog displayString buttons {_close} default button _close with title _title
- #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement