InstallHistory.plist file and OSX Installer information

laurendc
New Contributor

I was tasked with coming up with a way for us to figure out which OS version our machines were imaged with in the past. We currently don't have a breadcrumb on units to help figure this information out. (I plan on adding one in the next configuration update.) Our best bet was remoting into machines to read the contents of desktop wallpaper that gets saved on every new image that has the build configuration information on it.

Anyway, the best I could come up with was this - which doesn't account for build configuration info but will at least tell us which OS version the build started out with... it checks for the version of the OSX Installer process in /Library/Receipts/InstallHistory.plist.

OS=`/usr/bin/awk '/10.8/ || /10.7/ || /10.6/' /Library/Receipts/InstallHistory.plist | /usr/bin/cut -c 11-16 | /usr/bin/head -1`
/bin/echo "OS is $OS"

case "$OS" in
    *10.8.* )
        /bin/echo "<result>ML</result>"
    ;;
    *10.7.* )
        /bin/echo "<result>Lion</result>"
    ;;
    *10.6.* )
        /bin/echo "<result>Snow Leopard</result>"
    ;;
esac

I noted that the version of the OSX Installer process is the first one that appears in the list so this seemed to be a good route to think about for this. I'm basing this information off of the contents of the file, which doesn't appear to change in the pattern of listing the installer version information first:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>date</key>
        <date>2013-07-29T20:36:40Z</date>
        <key>displayName</key>
        <string>OS X</string>
        <key>displayVersion</key>
        <string>**10.8.3** (12D78)</string> **<- this is the info that I'm grabbing**
        <key>packageIdentifiers</key>
        <array>
            <string>com.apple.pkg.BaseSystemBinaries</string>
            <string>com.apple.pkg.BaseSystemResources</string>
            <string>com.apple.pkg.Essentials</string>
            <string>com.apple.pkg.BSD</string>
            <string>com.apple.pkg.JavaTools</string>
            <string>com.apple.pkg.RemoteDesktop</string>
            <string>com.apple.pkg.AdditionalEssentials</string>
            <string>com.apple.pkg.AdditionalSpeechVoices</string>
            <string>com.apple.pkg.AsianLanguagesSupport</string>
            <string>com.apple.pkg.MediaFiles</string>
            <string>com.apple.pkg.JavaEssentials</string>
            <string>com.apple.pkg.OxfordDictionaries</string>
            <string>com.apple.pkg.X11redirect</string>
            <string>com.apple.pkg.OSInstall</string>
            <string>com.apple.pkg.update.compatibility.2013.001</string>
        </array>
        <key>processName</key>
        <string>OS X Installer</string>
    </dict>

I'm wondering though - has anyone had to do anything similar? Is there a better way to gain this information from machines on the floor? I'd welcome hearing info from others regarding how they are tracking this information, or how they have to obtain it.

1 REPLY 1

tkimpton
Valued Contributor II

Hi

You could just not delete the imaging logs ever which should give you the OS Depending on your environment though may depend if it's possible because your logs could balloon in size depending on the number of machines.