Novell is now a part of Micro Focus

How to have Imaging Perform an Automated Task

Novell Cool Solutions: Feature
By Kenn White

Digg This - Slashdot This

Posted: 25 Nov 2002

This HOW TO document explains the process you may use to have Imaging perform an automated task. A common task would be to boot from CD, mount the CD and restore an imaged stored from the CD/DVD.

Please refer to the HOW TO on adding or replacing files on the boot media.


Available with Imaging v3.2 sp1 and V4.0, the imaging script has several capabilities built in that allow the processing to be changed from the "img auto" default processing.

Automating Imaging tasks

The normal processing that is performed when the Imaging Linux boots is "img auto", which runs the Imaging Engine and asks the proxy server for any tasks to run.

Now, let's say you have an image created that you want to be able to restore automatically, without asking the Imaging proxy for a task. There is a special change that can be added to the "settings.txt" file to accomplish this task. The command is "IMGCMD" (all caps).

For example, if you want to have a boot CD that will automatically restore an image named "Win2K.zmg" from the Imaging proxy without asking the proxy for work to do, you would add the following line to the "settings.txt" file:

export IMGCMD="img rp $PROXYADDR //server/path/Win2k.zmg"

Since the "IMGCMD" environment variable has been defined, the Imaging script will run this command instead of running "img auto".

You can actually do more advanced commands by placing them in a script file and running it in the same way. Let's say you have a script file named "myscript.s" that you want to run. This script can have any Linux commands in it that are located on the Imaging Linux boot media.
(Note: Not all commands, like ftp or telnet are part of the boot media.)

The first step would be to add the files required to the boot media. At a minimum, the script file needs to be added to the "/bin" directory and imaging must be told to run this script file. Add the script file to the root directory of the boot media.


You would then add the line to run your script file to the "settings.txt" file.

export IMGCMD="/bin/myscript.s"

Now when you boot, the file "myscript.s" is copied to the "/bin" directory and then the imaging script runs the "IMGCMD" or "/bin/myscript.s"

The script file "myscript.s" may contain any commands you desire. You may have commands to delete partitions, create partitions, restore an image from the proxy or local file system (CD) or even multiple combinations.

Note about the script file: You may or may not be aware that script files are not normal Windows ".txt" files. Linux script files do not have both the "carriage return, new line" characters terminating each line. Each line is terminated only with the "new line" character. If your script is a normal ".txt", Linux will fail when it encounters the "carriage return" character and the script will get errors.

Here are two ways to solve this problem.

1) Boot from the Imaging boot CD and create and test your script file. For your convenience, the text editor "pico" is contained in the Linux that is booted from CD. It is quite simple to edit files with this program.

Mount a diskette, copy the file to the diskette then unmount the diskette using the following commands.

mount /dev/fd0 /mnt/floppy
cp myscript.s /mnt/floppy
umount /mnt/floppy

Remember to unmount the floppy before removing it from the drive.

You can then copy the file from diskette on your Windows machine.

Do not edit the file from Windows.

2) Create the script file on a Linux machine and FTP the file to the Windows machine using binary mode file transfer. FTP will not convert the line terminators, thus leaving them in a Linux compatible mode. If you do this, DO NOT edit the file again on the Windows machine.

More Info

For more help with ZENworks Imaging, don't miss the ZENworks Imaging Resource Library.

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates