Script parameters/variables when imaging

bentoms
Release Candidate Programs Tester

As you can gather from my previous questions, we're about to deploy a few more machines.

Basically, I'll be taking a retail DMG, combo updating & then using a combination of various scripts to set things such as time server, timezone, binding to od group etc...

The scripts i'm using all have the correct parameter labels, but for each configuration i wish to change some/all of the variables. (i.e one configuration will bind to one OD group, another.. another group etc..)..

Rather than hardcode each script, I'd like to declare the variables at imaging.

Now i know we can do this via casper remote or a policy, BUT how do you guys do this?

Pre-stage isn't an option sadly.

I was thinking i'd create a policy with all the scripts, duplicate it per each config & give each policy a manual trigger.

That way i can change the variables through the jss web interface (making dynamic changes easy), & only have a one line script needed per configuration..

Does any of that make sense? have I over complicated things?

Grey Communications Group Limited
Registered No. 1795794, Registered in England
Registered Office The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
VAT Number GB 404 6245 78

1 ACCEPTED SOLUTION

bentoms
Release Candidate Programs Tester

Ben, are you saying that you'd like to put the customized script into each configuration and just declare what that $4 should be at that time? This may be a decent work-around until Casper lets you do that.

^^ Yep that's pretty much it.. I've taken a 10.6 DMG from an install DVD & have scripted the whole build using the resource kit scripts & some of my own.

The "add to od group" script is a good example. $4 is you OD, $5 diradmin username, $6 diradmin password, $7 Computer group.

The variable $7 Computer Group will need to be different for each business units configuration.

We do not wish to hardcode these values in the scripts due to security & flexibility issues.

But, by assigning the values at a policy level & triggering the policy via a custom trigger seems to do the job.

Grey Communications Group Limited
Registered No. 1795794, Registered in England
Registered Office The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
VAT Number GB 404 6245 78

View solution in original post

7 REPLIES 7

tlarkin
Honored Contributor

Are you referring to global variables that any system can call outside a script? I think I follow, but am not sure. Can you elaborate a bit?

bentoms
Release Candidate Programs Tester

I mean variables like $4 etc that you can set via Casper remote or a policy.

Regards,

Ben.

bentoms
Release Candidate Programs Tester

Thanks again Miles. But i'd ideally want it set at a configuration level.

Say we use the settimeserver.sh from the resource kit across our configurations. The script uses $4 as the variable for the timeserver.

One configuration will need to point to one time server, & another configuration anoter server.

Through policies or Casper remote we can set $4. But I'd like to set it at a configuration stage.

This way we could utilise the scripts within the resource kits across a range of environments & manage these settings centrally.

ATM the only way I can see to do this would be to create a policy with these variables set & trigger the policy via the firstrun script (i.e. UKCreativeSetup, UKHealthcareSetup or FRCreativeSetup).

Regards,

Ben.

milesleacy
Valued Contributor

At the moment, a policy seems like the best way to get this done.

This sounds like a great feature request, though.

Thanks,

--
Miles Leacy
Technical Training Manager
Mobile (347) 277-7321

miles at jamfsoftware.com<mailto:miles at jamfsoftware.com>
....................................................................
JAMF Software
1011 Washington Ave. S
Suite 350
Minneapolis, MN 55415
....................................................................
Office: (612) 605-6625
Facsimile: (612) 332-9054
....................................................................
US Support: (612) 216-1296
UK Support +44.(0)20.3002.3907
AU Support +61.(0)2.8014.7469
....................................................................
http://www.jamfsoftware.com<http://www.jamfsoftware.com/>

jarednichols
Honored Contributor

Hi-

We do (kind of) what (I believe) Ben is trying to do. For instance, we have
a script that sets a user as an Admin-level user:

#!/bin/sh
user=$4
dscl . -append /Groups/admin GroupMembership $user
exit 0

We run this script during imaging to pre-populate the user's Active
Directory user ID into the Admin group. The first time they log in, their
user is already in the Admin group. Pretty sweet.

Procedurally, what we do is select the pre-compiled configuration in Imaging
and then hit the custom button. Go to the scripts tab, select the script,
then populate into the first variable field the user ID (that's $4 which up
above you can see we set to the variable Œuser'). If you set the script to
run at reboot, this makes sure you're still using the compiled configuration
so the imaging is still very quick.

Ben, are you saying that you'd like to put the customized script into each
configuration and just declare what that $4 should be at that time? This may
be a decent work-around until Casper lets you do that.

j

On 3/16/10 9:28 AM, "Miles Leacy" <miles.leacy at jamfsoftware.com> wrote:

bentoms
Release Candidate Programs Tester

Ben, are you saying that you'd like to put the customized script into each configuration and just declare what that $4 should be at that time? This may be a decent work-around until Casper lets you do that.

^^ Yep that's pretty much it.. I've taken a 10.6 DMG from an install DVD & have scripted the whole build using the resource kit scripts & some of my own.

The "add to od group" script is a good example. $4 is you OD, $5 diradmin username, $6 diradmin password, $7 Computer group.

The variable $7 Computer Group will need to be different for each business units configuration.

We do not wish to hardcode these values in the scripts due to security & flexibility issues.

But, by assigning the values at a policy level & triggering the policy via a custom trigger seems to do the job.

Grey Communications Group Limited
Registered No. 1795794, Registered in England
Registered Office The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
VAT Number GB 404 6245 78

tlarkin
Honored Contributor

I guess it would be possible to set a group or an array of global
variables in a config or plain text or XML file somewhere on every
system, and then have all your scripts source that file for those global
variables. That way you could set something like:

$1 = computer name

$2 = Ethernet MAC address

so on and so forth, and then source out those variables in every script
you write. You could also copy this script, in say your Netboot image
and have it declared by it's full path in the script. I did this sorta
back in Casper 5.x days. I had a disk wipe command that I put into the
netboot installer so you could you drop to a terminal window and just
type in diskwipe.command and it executed as root and ran that small
script to wipe and rename /dev/disk0. However, later on I just had
Casper run it as a script. I guess you could also edit the root user's
~/.bash_profile and set all sorts of functions and aliases in your
netboot image. That way you could set global parameters and run
commands that way as well.

If this is what you are getting at, and if not, just ignore what I
posted then. I have not finished my cup of coffee yet this morning so I
may still be a bit slow.

-Tom