Deployment Solution

 View Only

Linux Automation Scripting Tips and Tricks 

May 14, 2009 05:50 PM

There seems to be a serious lack of documentation on the Internet regarding this subject, so this is as good of a place to start it. I'm throwing everything that I've run across in here so others may benefit. All of this was documented on DS 6.8 SP1

We have been using DOS automation since we began using Altiris a couple of years ago. Our base image is about 1.5 gigabytes after all of our customizations, and this image would typically take approximately 15 minutes to deploy on various Dell-based systems ranging from old OptiPlex GX150's to the newest OptiPlex 745's.

We were interested in speeding this process up by utilizing a different form of automation. WinPE was looked into, however the extra time it took to boot into automation negated the speed benefits of using it as our automation platform. We decided to implement Linux automation instead, since it had the fast bootup like DOS and faster transfer speeds that WinPE provided.

I'm far from a Linux expert. Scripting our deployment jobs is the only real experience I have had with Linux. I'm hoping this will provide a useful perspective for those who may be in my shoes and want to speed up their imaging processes. The code may be messy, but it works.

Notes for first-timers regarding some key differences between DOS and Linux:

  • Slashes, not backslashes. This will be especially important if you're converting an existing script.
  • No drive letters. Linux uses folders for "mapped drives". Instead of mapping your eXpress share to F: like in DOS, it gets mapped to /mnt/ds/ instead.

The "Create Disk Image" and "Distribute Disk Image" tasks:

You'll want to ensure you're using rdeployt for your imaging tasks, as there is no graphics-mode rdeploy like there was in DOS.

Keep in mind that since this will be running under the Linux automation, you'll need to format your path/file names in Linux format. For example, if your disk image is in \\AltirisServer\eXpress\Images\Standard.img, you'll want to key in /mnt/ds/images/Standard.img instead. Be sure to check the checkbox immediately underneath the text box. Windows doesn't know what the /mnt/ds/ path is since it's not in a Windows-based format, so it will bark at you that it doesn't exist. By checking this box, you won't receive any warnings about it.

Scripting:

  • Any commands that are executed in a script will not output to the screen by default. You can make these commands output to the screen by adding "> /dev/tty1" (without quotes) to the end of the line.
  • Add the following line to your script near the top to put the /mnt/ds/RDeploy/Linux folder in the path so you don't need to keep typing the full pathname to rdeployt and firm: export PATH=$PATH:/mnt/ds/RDeploy/Linux
  • Token replacement is done the same way as DOS; just change the REM to # instead.
  • Variables are assigned by simply typing VARIABLENAME=contents. They are referenced by $VARIABLENAME after they are set.

Logic / Driver Injection:

I've found the case statement to work more reliably than if statements.

This example will set the workstation's product name as the MDOEL variable and inject the appropriate drivers to the C:\DRV folder on the workstation.

Code:

MODEL="%#!computer@prod_name%"
case "$MODEL" in
'OptiPlex GX260')
Firm -recurse Copy "/mnt/ds/Drivers/GX260" "prod:/drv"
;;
'OptiPlex GX270')
Firm -recurse Copy "/mnt/ds/Drivers/GX270" "prod:/drv"
;;
'OptiPlex GX280')
Firm -recurse Copy "/mnt/ds/Drivers/GX280" "prod:/drv"
;;
esac

Creating multiple mounts to the same server:

There is a known issue with DS 6.8 where automation will crash if two mount points are created to the same server. In some setups, you may want to have a common reference that changes based on the client's IP address.

This example will check the client's IP address, and based on the third octet (assuming only 2 digit numbers are used) will map /mnt/img to either the eXpress share's Images subdirectory or mount this folder to a different server altogether. This could be useful if you want a machine to use a local file server to pull down an image from a local server instead of pulling the image across a WAN.

Examine the mounts.local file in the etc folder through boot disk creator to see how the asmbmount command is used to mount the eXpress share and modify the line below to fit your environment. This example assumes that the 10 subnet is a remote subnet and the 20 subnet is a local subnet (to the Altiris server), and that the \\ALTIRISSERVER\eXpress\Images folder structure is identical to the \\SERVERNAME\ShareName folder structure.

Code:

LONGIPADDR=%AGENTIPADDR%
IPADDR=${LONGIPADDR:6:2}
case "$IPADDR" in
'10')
mkdir /mnt/img
asmbmount -b -d DOMAIN -f /Account.pwl //SERVERNAME/ShareName /mnt/img
;;
'20')
/bin/ln -s /mnt/ds/images /mnt/img
;;
esac

Put all of these concepts together, and we can address the following scenario:

A company has their headquarters in New York and a satellite office in San Diego. The Altiris server is located in New York. All machines in New York have IP addresses in the 10.10.50.xxx range and all machines in Los Angeles have IP addresses in the 10.10.60.xxx range. Their Altiris server's name is NEWYORK. There is a server in San Diego named SANDIEGO, which has an Images share containing the same image found in the eXpress/Images share on the Altiris server named WinXP.img. They would like a single script to image PC's in both locations without streaming the images across the country.

Code:

export PATH=$PATH:/mnt/ds/RDeploy/Linux

LONGIPADDR=%AGENTIPADDR%
IPADDR=${LONGIPADDR:6:2}

case "$IPADDR" in
'50')
/bin/ln -s /mnt/ds/images /mnt/img
;;
'60')
mkdir /mnt/img
asmbmount -b -d DOMAIN -f /Account.pwl //SANDIEGO/Images /mnt/img
;;
esac

rdeployt -md -f/mnt/img/WinXP.img

MODEL="%#!computer@prod_name%"
case "$MODEL" in
'OptiPlex GX260')
Firm -recurse Copy "/mnt/ds/Drivers/GX260" "prod:/drv"
;;
'OptiPlex GX270')
Firm -recurse Copy "/mnt/ds/Drivers/GX270" "prod:/drv"
;;
'OptiPlex GX280')
Firm -recurse Copy "/mnt/ds/Drivers/GX280" "prod:/drv"
;;
esac

exit 0

If anyone else has anything to add, feel free. Hopefully those who take the plunge will be able to do so with little trouble.

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

May 16, 2009 06:29 PM

 that's really helpful!

Related Entries and Links

No Related Resource entered.