Smart Group or Extension Attribute to determine Application Size

jstine
Contributor

Hello,

Does anyone know if there is anyway to create an EA or Smart Group based on the size of an Application. For our MacOS High Sierra upgrade, I'm caching the installer in Applications/, and am scoping a script to run the installer on machines who have the application Application/Install MacOS High Sierra.app, but I want to make sure that the full installer was downloaded so that Jamf doesn't automatically try to kick off an install on an installer that was only partially downloaded.

Any ideas?

4 REPLIES 4

pcrandom
Contributor

You could try this for an extension attribute:

#!/bin/bash

if [ -d "/Applications/Install macOS High Sierra.app" ]; then
    appSize=$(du -ms "/Applications/Install macOS High Sierra.app" | awk '{print $1}' )
    if [ "$appSize" -ge "4973" ]; then 
        echo "<result>Cached</result>"
    else
        echo "<result>Incomplete</result>"
    fi
else
    echo "<result>Uncached</result>"
fi

Adjust the filename and the application size accordingly.

StoneMagnet
Contributor III

@jstine Possibly easier would be to have the process that caches the app drop a breadcrumb file on successful download which you have an EA test for as an indicator the install can start.

And I take it you're not wanting to trigger the install as soon as the download completes?

jstine
Contributor

@pcrandom Thank you, I'm going to give this a try.

Is that filesize in the EA in bytes or kb?

The installer I'm using is 5,214,297,228 bytes, or 5.21GB.

pcrandom
Contributor

@jstine That size is in MB and is the size reported to me when I run du -ms on my copy of the 10.13.2 High Sierra installer. If you have a fully downloaded copy of whichever installer you're caching, run the command to see what size it comes out as in MB.

My installer shows a similar-sized 5,207,413,213 bytes (5.21 GB on disk) in Get Info, but 4973 is the number of 1048576-byte (1-Mbyte) blocks when I run the du -ms on it.