Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ###
- #
- # Name: shard.sh
- # Description: This Casper extension attribute takes a Mac serial
- # number as input and uses that serial number to output a
- # number from 1 to 10. This can be useful in scoping Casper
- # policies to a specific percentage of the fleet.
- # Author: Elliot Jordan <elliot@lindegroup.com>
- # Created: 2015-05-15
- # Last Modified: 2015-05-15
- # Version: 1.0
- #
- ###
- SERIAL=$(ioreg -c IOPlatformExpertDevice -d 2 |awk '/IOPlatformSerialNumber/ {print $3}' |sed s/\"//g)
- HEX=$(echo "$SERIAL" | md5 | colrm 1 28) # 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement