Skip to content

Instantly share code, notes, and snippets.

@binkleybloom
Created November 15, 2017 14:27
Show Gist options
  • Save binkleybloom/3a21186f6df60d650c68436c9018e0d8 to your computer and use it in GitHub Desktop.
Save binkleybloom/3a21186f6df60d650c68436c9018e0d8 to your computer and use it in GitHub Desktop.
Sets Munki Client Identifier within Deploy Studio
#! /bin/bash
## This script first checks for a Custom Pref "MUNKIID", then for a value in ARD field #4, then finally for the computer name.
## When it locates the first value in order, it sets the ClientID of the system.
## This script must be run after the first reboot and MunkiTools & initial preference installation, during the Deploy Studio
## Finalize steps.
##
## Tim Schutt, Syracuse University. 2015
echo -e " \n=============== Setting Munki Client ID ====================="
TEXTID=$(defaults read "/Volumes/${DS_LAST_SELECTED_TARGET}/Library/Preferences/com.apple.RemoteDesktop" Text4)
echo -e " \n MUNKIID Custom Pref Value: ${MUNKIID}\n ARD Text4 value: $TEXTID\n\n Computer Name: $DS_COMPUTERNAME \n"
if [ ${MUNKIID} ]
then
echo -e "\n MUNKIID exists in Deploystudio Workflow. \n"
CLIENTID="${MUNKIID}"
elif [ $TEXTID ]
then
echo -e "\n No MUNKIID value found. ARD Text4 Field exists. \n"
CLIENTID=$TEXTID
else
echo -e "\n No MUNKIID value or ARD Text4 value found. Setting ClientID to Computer Name. \n"
CLIENTID=$DS_COMPUTERNAME
fi
defaults write "/Volumes/${DS_LAST_SELECTED_TARGET}/Library/Preferences/ManagedInstalls" ClientIdentifier "$CLIENTID"
echo " Munki ClientIdentifier has been successfully set to '$CLIENTID'"
echo -e " \n========= Finished Setting Munki Client ID ===================="
echo -e " \n "
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment