You are not logged in.


[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 2012-09-19 19:13:36

Registered: 2008-10-19

ENHANCEMENT: Target volume selection with 'Returned by script...'


I think that Target volume selection should have an option 'Returned by script...'

This way we could programmatically select the target volume based on the output of a customized script.


#2 2012-12-03 15:51:09

Registered: 2011-08-30

Re: ENHANCEMENT: Target volume selection with 'Returned by script...'

Generally speaking, having values returned by script would be useful. 

I'm using a modular workflow for our staff images where all the software gets deployed by munki after the OS is deployed by DS.  This typically isn't problematic but consider 10.8.2, and 10.7.4, where there were multiple unique builds to support models released between minor OS versions.

It would be extremely useful to be able to specify the image value as "Returned by script..." for the Restore Volume task in this scenario.  I understand that I can have a bunch of hidden workflows called by the metaworkflow task for each base OS image but it isn't optimal.


#3 2014-06-13 07:58:10

Registered: 2008-10-19

Re: ENHANCEMENT: Target volume selection with 'Returned by script...'

I had an idea how this could be implemented using a script task before image restore task.
It demands that Restore target should be set to something like DS_TARGET_VOLUME.
The prerun script will do its magic and renames or formats the wanted partition named as DS_TARGET_VOLUME.
I will post some test results in a few days.

However, I still think it would be easier to have it in Restore image task as a feature.
There should be a fallback to "User selection" dialog.


#4 2014-11-14 00:14:35

Registered: 2014-06-27

Re: ENHANCEMENT: Target volume selection with 'Returned by script...'

How did this work out?  Do you have an example of how this worked?  I have a similar script that I would need to run before the restore task and then output the image file name to variable for the Restore Image Filename to reference.

Did you find a workaround to get this to work?


#5 2014-11-18 16:55:30

Nathan Fisher
Registered: 2014-08-13

Re: ENHANCEMENT: Target volume selection with 'Returned by script...'

>> Did you find a workaround to get this to work?

I've set up a system of information exchange using the deploy studio share mount.  Make a folder there ($DS_REPOSITORY_PATH) and say... put something in a file named by the computer's serial number ($DS_SERIAL_NUMBER) with the information you want to pass to the next script.  Maybe name the file "$DS_REPOSITORY_PATH/handoffs/${DS_SERIAL_NUMBER}_goto_script" and store the script ID there.

then have a generic workflow that looks for that file and returns the contents of the file as a string, and that workflow is set to chain to the next workflow by name.

one "state" my machines can be in is "waiting for remote command".  I can have an entire lab sitting there waiting for command files (either to them specifically, or to all of them) to appear in their shared command folder on the DS server.  They load them and can do things like change startup disk and reboot, shut down, change startup to Macintosh HD and reboot, start a specified workflow, download and run a specified script, etc.  It behaves somewhat like remote desktop in that respect, I can boot up a lab of machines, and go work on the image, and when it's ready, (or when the previous lab is done hammering the network) I can turn 'em loose.

Be careful of race conditions when writing such files to exchange information.  Despite my best efforts, it's maddeningly difficult to write a completely bulletproof semaphore to be able to write to a shared file. (necessary for my queued restore system I use here)  I've even seen so much as two machines trying to write to the semaphore lock file at the same time (via >>, a file append, which SHOULD be atomic on the file server!) only to find SN's XXXXX and YYYYY written as XXYYYYYXX instead of one after the other.  I don't think I even want to know how Apple allowed that to happen.


#6 2014-12-16 11:14:47

Registered: 2008-10-19

Re: ENHANCEMENT: Target volume selection with 'Returned by script...'


for reformatting the first internal disk device I have used the following script.

This has been modified from the version I am running, it may or may not work directly...


# get the 1st internal device and format and repartition it with the name DS_TARGET_VOLUME.

SCRIPT_NAME=`/usr/bin/basename "${0}"`

/bin/echo "${SCRIPT_NAME} - v 2014.8.12 ("`date`")"

# define name for target partition

# actions

getDeviceList=$(diskutil list | grep '/dev/disk' | tr '\n' ' ' | sed 's/.$//g;s/\/dev\///g')

getInternalDrivesList=$(for dev in ${getDeviceList}; do diskutil info "${dev}" | grep -i 'Internal:' | grep -ioq 'yes' && echo "${dev}" | tr '\n' ' ' | sed 's/.$//g' && break; done)

if [ "" == "${getInternalDrivesList}" ]; then
    exit 1

echo "INTERNAL DRIVES: ${getInternalDrivesList}"

# format the first internal disk
for dev in ${getInternalDrivesList}; do

    # first wipe the whole device
    diskutil eraseDisk JHFS+ "${dsTargetName}" "${dev}"
    # else format with a single partition
    echo "Formatting drive '${dev}' with 1 partition..."

    diskutil partitionDisk "${dev}" 1 JHFS+ "${dsTargetName}" R 2>&1
    sleep 2
    diskutil list "${dev}"

    if ! diskutil list "${dev}" | grep -q "${dsTargetName}"; then
        echo "ERROR: could not find '${dsTargetName}' on '${dev}'"
        exit 1
        echo "OK: found '${dsTargetName}' on '${dev}'"   


exit 0


As you can see it will rename the formatted disk with name 'DS_TARGET_VOLUME'.
So the next step would be 'Restore (Image)' with the target name set to 'DS_TARGET_VOLUME'.
If the specified target disk is not found the task will wait until user selects the target disk manually.
If the specified target disk is found then it will automatically restore the specified image on that target, presuming that Restore task is set to 'Automate'.

This script probably cannot handle Fusion drives as they have CoreStorage enabled.
The target drive should have CoreStorage disabled first, after that you can restore image on that drive.
I have not yet enough experience with Fusion/CoreStorage Macs with DeployStudio so I cannot give any guidance on how to handle those.

Run this script only on a test computer that has no valuable data on the disk, it will destroy all partitions on the target disk.

And at this time I cannot provide any further support with this...maybe in January...

Anyway, I hope this will help someone.




Board footer

Powered by FluxBB