Deploystudio Netboot Update

When apple releases a new model of Mac that your organization decides to purchase and use, then you have to create a whole new netboot image to support the new hardware. If you don’t update your previous netboot sets then when you try to image this new model of Mac you will find that once it reboots after running through the DeployStudio workflow you will get a folder with a question mark.

This isn’t so bad if you have just one server to update the netboot set on, but if you have 70 like we do then it could take a while to manually update the netboot image on every single server. To speed things up I’ve created the following script that does all the hard work for me.

For this to work correctly you must meet the following criteria:

  1. You must be using DeployStudio and already have a netboot set created.
  2. You must place your new updated netboot in the /Users/Shared/ folder.
  3. Replace NetbotImageName.nbi in the script with the actual name of your new netboot.nbi.

I prefer to package the netboot image and the script together so that I can just deploy the package through Absolute to fully automate the process. To do this you simply need to set the package payload to put the new netboot image in the /Users/Shared/ folder and then run the following script as a post flight script.

#Gets path to current netboot image
Path=$( sudo /Applications/ settings netboot | grep pathToImage | awk '{ print $3 }' | rev | cut -d / -f 3- | rev | cut -c 2- )
#Gets current netboot image name
NB=$( sudo /Applications/ settings netboot | grep pathToImage | awk '{ print $3 }' | rev | cut -d / -f 2 | rev )
echo "Path to NetBoot is $Path"
echo "NetBoot Name is $NB"
echo "Full path is $Path/$NB"
if [[ "$Path" = "$null" || "$NB" = "$null" ]]
echo "The NetBoot path was null" >> /var/log/install.log
exit 1
echo "Removing $Path/$NB"
sudo rm -R $Path/$NB
echo "Moving /Users/Shared/NetbootImageName.nbi to $Path/$NB"
sudo mv /Users/Shared/NetbootImageName.nbi $Path/$NB
sleep 15
#Checks to see if the netboot image was copied successfully
if [[ -r "$Path/$NB/NetInstall.sparseimage" ]]
echo "Netboot successfully moved."
echo "Netboot not moved."
echo "Mounting $Path/$NB/NetInstall.sparseimage"
hdiutil attach -readwrite $Path/$NB/NetInstall.sparseimage
NBName=$(echo $NB | cut -d . -f 1)
echo "NBName is $NBName"
echo "waiting 5 seconds"
sleep 5
DStudioVolumeName=$( ls /Volumes/ | grep NetbootImageName )
echo "DStudio Volume Name is $DStudioVolumeName"
/usr/libexec/PlistBuddy -c "Set server:url http://$HOSTNAME:60080" "/Volumes/DeployStudioRuntime/Library/Preferences/com.deploystudio.server.plist"
Verify=$( defaults read /Volumes/$DStudioVolumeName/Library/Preferences/com.deploystudio.server.plist | grep url )
echo "New server url is $Verify"
if [[ "$Verify" = "$null" ]]
echo "failed to write com.deplystudio.server plist"
exit 1
echo "Writing $Path/$NB/NBImageInfo.plist Description string $NBName"
echo "Writing $Path/$NB/NBImageInfo.plist Name string $NBName"
defaults write $Path"/"$NB/NBImageInfo.plist Description -string $NBName
defaults write $Path"/"$NB/NBImageInfo.plist Name -string $NBName
sudo chmod 644 $Path/$NB/NBImageInfo.plist
sleep 5
hdiutil detach /Volumes/$DStudioVolumeName

Leave a Reply

Your email address will not be published. Required fields are marked *