Last active
November 7, 2025 20:32
-
-
Save homebysix/b35f1979d5b11e00602c to your computer and use it in GitHub Desktop.
shard.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### | |
| # | |
| # Name: shard.sh | |
| # Description: This Jamf Pro extension attribute takes a Mac serial | |
| # number as input and uses that serial number to output a | |
| # number from 0 to 9. This can be useful in scoping Jamf | |
| # policies to a specific percentage of the fleet. | |
| # Author: Elliot Jordan <[email protected]> | |
| # Created: 2015-05-15 | |
| # Last Modified: 2025-11-07 | |
| # Version: 1.0.2 | |
| # | |
| ### | |
| SERIAL=$(ioreg -c IOPlatformExpertDevice -d 2 | awk '/IOPlatformSerialNumber/ {print $3}' | sed s/\"//g) | |
| HEX=$(echo "$SERIAL" | md5 | tail -c 5) # last four hex digits of the serial's md5 | |
| DEC=$(( 16#$HEX )) # number between 0 and 65535 | |
| SHARD=$(( DEC % 10 )) # number between 0 and 9 | |
| echo "<result>$SHARD</result>" | |
| exit 0 |
Author
Not one that I use, but Mr. Gilbert has something similar in Python here: https://grahamgilbert.com/blog/2015/11/23/releasing-changes-with-sharding/
Much appreciated!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a python version of this?