Skip to main content
Question

Using File Modification Dates as Version Numbers


dan-snelson
Forum|alt.badge.img+28

Background

Inspired by John Eberle's, Louise Radifera's and Alex Smith's presentation "Supplementing Jamf's reporting with MunkiReport (JNUC305)" at JNUC 2020, we're now test-driving MunkiReport 5.6.3.4224.

After learning the hard way that a new client installer is needed each time I enabled a new module, I could no longer rely on a Jamf Pro Extension Attribute of munkiReportVersion=$( /usr/bin/defaults read /Library/Preferences/MunkiReport Version ) since every test Mac was already running 5.6.3.4224, but not my latest installer of version 5.6.3.4224.

In early testing, switching to using file modification dates as version numbers seems to be working well.


Extension Attribute

Determine the location of a critical file which is only modified by your installer package and enter its path in the testFile variable. (In this use-case, I decided not to use /Library/Preferences/MunkiReport.plist as I'm purposely modifying scriptTimeOut during testing.)

Next, establish a bogus date for computers which will not have testFile; in this case, I used 2020-01-01 20:01:01.

Create a new Computer Extension Attribute:
- Data Type: Date
- Input Type: Script

#!/bin/sh
# Extension Attribute to detect presence of MunkiReport Runner

# munkiReportVersion=$( /usr/bin/defaults read /Library/Preferences/MunkiReport Version )

testFile="/usr/local/munkireport/munkireport-runner"

if [ -f "${testFile}" ] ; then
    result=$( /bin/date -j -f "%s" "$(/usr/bin/stat -f "%m" $testFile)" "+%Y-%m-%d %T" )
else
    echo "<result>2020-01-01 20:01:01</result>"
fi

echo "<result>$result</result>"


Smart Group

Create a new Smart Group which references your Extension Attribute, with an Operator of after (yyyy-mm-dd) and the year, month and day of your installer package:

Each time you re-deploy your installer package, remember to update the value in the Smart Group.


Possible Gotchas

While the Extension Attribute includes the file modification time, the Smart Group apparently does not. If you're iterating multiple times on the same day, please plan accordingly.

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings