You are not logged in.

Announcement

[2017.09.08] DeployStudio build v1.7.8 (checksum, release note).
[2016.08.26] DeployStudio build v1.6.19 (release note).
[2013.02.23] DeployStudio last universal build v1.5.17 (release note).

#1 2014-02-28 17:17:04

jelockwood
Member
Registered: 2009-11-11

fix ByHost files - script for you

DeployStudio has a built-in function to fix ByHost preference files, these are preference files in a sub-folder of the users preference folders and are for settings specific to an individual Mac. However the built-in function in DeployStudio to do this runs as part of the restore image process which means it will only work if the image being restored has such preference files contained within it.

Sometime ago I switched to a thin-imaging approach using AutoDMG (and before that InstaDMG) and as a result the image being restored has no preferences in it as it is a virgin never run image generated directly from a download from the App Store. I now copy pre-configured preference files on the Mac after the image has been restored using a dil copy workflow step. This means as mentioned above DeployStudio cannot do the ByHost renaming for me.

I have written the following script to do this as a generic script task in the workflow after copying the files. Feel free to adapt it to suit your own purposes.

#!/bin/bash
# collect new ByHost filename(s) for destination Mac which is the hardware UUID
if [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` == "00000000-0000-1000-8000-" ]]; then
newUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c51-62 | awk {'print tolower()'}`
elif [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` != "00000000-0000-1000-8000-" ]]; then
newUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62`
fi
echo $newUUID
# Some silly evals to get around the path having a space in it
DIRECTORY="/System/Library/User\ Template/English.lproj/Library/Preferences/ByHost"
eval ifDIRECTORY="$DIRECTORY"
# If ByHost directory exists then do renaming
if [ -d "$ifDIRECTORY" ]; then
echo "exists"
# CD to directory and then rename all matching files in it
eval cd $DIRECTORY
for file in *.????????-????-????-????-????????????.plist; do
    mv "${file}" "${file/%.????????-????-????-????-????????????.plist/.$newUUID.plist}"
done
else
echo "not exist"
fi
# Pointless pwd just to show it was in the right place
pwd
exit

Offline

#2 2014-03-03 09:05:07

homerdjw
Member
From: London, England
Registered: 2013-01-24
Website

Re: fix ByHost files - script for you

Hi jelockwood,

Pardon my ignorance, but if you build an image using AutoDMG (or even InstaDMG) as it's un-booted, should there not be any ByHost prefs at all?

Just curious!

Thanks

Darren

Offline

#3 2014-03-03 11:35:51

jelockwood
Member
Registered: 2009-11-11

Re: fix ByHost files - script for you

> homerdjw wrote:

> Hi jelockwood,
>
> Pardon my ignorance, but if you build an image using AutoDMG (or even InstaDMG) as it's un-booted, should there not be any ByHost prefs at all?
> Just curious!
>
> Thanks
> Darren

Yes, an image initially created by AutoDMG or InstaDMG will not have any ByHost prefs, during my Workflow I copy some preference files to /System/Library/User Template/English.lproj/Library/Preferences and /System/Library/User Template/English.lproj/Library/Preferences/ByHost these are then copied to the users home directory when they first login. Because I am copying the files after the image has been restored, DeployStudio cannot itself rename these files, DeployStudio can only itself do this if the files were already in the image itself. By using my script during the workflow the ByHost files I just copied are renamed to match to freshly imaged machine and so when the user logs in and triggers their copying to the new user home directory they get a set of pre-configured ByHost preferences with the correct file names. So the steps are -

1. Restore un-booted image
2. Copy pre-configured preference files to User Template folder
3. Rename files in ByHost folder in User Template folder
4. Workflow completes
5. User logs in and gets copies from User Template folder

Offline

#4 2014-04-03 21:46:05

Meat
Member
From: SF CA US
Registered: 2009-02-04

Re: fix ByHost files - script for you

Hi jelockwood,
A couple of things. You are running this as a postponed task?
Also, I noticed it doesn't change the name of the .GlobalPreferences... ByHost file.

Last edited by Meat (2014-04-03 22:44:23)

Offline

#5 2014-04-03 23:29:00

jelockwood
Member
Registered: 2009-11-11

Re: fix ByHost files - script for you

Yes I am running it as a postponed task. Regarding that file, I missed that one, I will have to go back and check and if necessary add that.

Offline

#6 2014-04-08 22:18:02

admin
Administrator
Registered: 2007-03-29
Website

Re: fix ByHost files - script for you

We'll add a "rename byhost files" option to the configure task in next build.

Offline

#7 2014-04-09 00:38:29

Meat
Member
From: SF CA US
Registered: 2009-02-04

Re: fix ByHost files - script for you

Thanks, admin! :)

Offline

Board footer

Powered by FluxBB