Monday, April 16, 2007

HOWTO Automatically Configure Clients After Imaging Them with SystemImager (Any Distribution)

You've imaged your 300 workstations, now they're identical

Do you need to run around and manually set up things, making sure that they have unique hostnames? that they they're setup to the right printer? Heck no!

With this handy-dandy system, let them do all that work themselves!


I've only been working with Linux for about a year and a half, even less than that with SystemImager. There may indeed be a better way to skin this cat. This is what I've figured out and used, and it's worked fine for me. Your Mileage May Vary (YMMV).

Some familiarity with bash scripting will allow you to modify this basic concept to better suit your particular needs. It's just a couple of bash scripts and a text file, but it's saved me a lot of time and work.

The setup

There are a few pieces to this puzzle, so let's describe them and then explain what will happen during the imaging process to save us so much work:


This is a script that is run at the end of the booting-up process, we'll use this in order to set it up so the workstations know when they need to execute the workhorse of this process. We simply add the following lines somewhere in the script (probably the beginning, right after the comments):

# This bit will launch the autoconfiguration routine when it's needed

# i.e. if the MAC address does not match the golden client, and the hostname is nordx--image


test `ifconfig | grep -c $GOLDENCLIENTMACADDRESS` == 0 && test `cat /etc/hosts | grep -c nordx--image` == ` && . /home/administrator/scripts/autoconfig

Note that you should put your Golden Client's MAC Address there instead of mine ;-)

Also note that we don't have a laptop that is dedicated to be a Golden Client. We use Laptop #1 as a Golden Client, and then we put it out for use. When we need to modify the laptop image, we re-image Laptop #1 back to it's Golden Client state, modify it how we want it, grab the new image, and then we put it back out for use. This means that we cannot rely on the /etc/rc.local script to know when it's time to configure this particular laptop and need to tell it manually. We do that by simply running $ sudo /home/administrator/scripts/autoconfig when we're done using it as a Golden Client.


This comma-delimited text file is stored on the server (nordx-server, here at North) and is available through the server's Apache server (via the wget command in the autoconfig script.). It contains a listing of every workstation with their MAC address, their hostname, what classroom and workstation number they are assigned, and some comments. This information will enable the workhorse of this process to perform the correct operations on every workstation.

A short example of what ours looks like:

MAC Address,Hostname,Classroom,Workstation,Comments

00:16:76:64:6F:A3,nordx--60500,605,0,210L teacher




00:13:20:90:7F:16,nordx--60900,609,0,170L teacher




00:16:76:64:68:E2,nordx--70601,706,0,210L test machine

00:13:20:99:DC:EF,nordx--70602,706,0,170L test machine

00:13:20:D7:E9:E3,,,,170L Replacement 1

00:13:20:99:DD:37,,,,170L Replacement 2

00:13:20:D8:1D:C1,,,,170L Replacement 3

00:15:C5:73:2F:A8 00:16:CF:A4:41:63,nordx--lap01,lap,1,1300

00:15:C5:73:0C:2D 00:16:CF:A4:43:C9,nordx--lap02,lap,2,1300


The MAC address is a unique identifier on each computer that will allow us to know, by reading the rest of the line, to know what computer we're at. Note that the laptops have two MAC addresses separated by a space rather than one; this is because they have both an ethernet adapter and a wireless network adapter.

If a computer were to die, we would replace it with one of our replacement computers, and change it's MAC address in this list for the one on the replacement computer, re-image or update the replacement, and it'd be good to go!


This is the workhorse of the process. Everything else is in place to make sure this script knows when to run and where it is running.

This script will run all the post-imaging configuration we want to do to the recently-imaged workstations. You can set this up to do whatever you need on that unique workstation based on information gleaned from workstations.csv on the Apache server.

It's pretty long, so I'll just direct you to a copy of the one we're using, if you want to check it out. You'll need a basic understanding of bash to modify it, but bash is pretty human legible, so you can probably get the gist of what's going on by taking a glance.

The important part to note is the very top, here:

# First, let's determine where we are by searching for our MAC address

# in the workstation information file, and pass that information into usable

# variables.

MAC=`ifconfig | grep -m 1 HWaddr | awk -F 'HWaddr ' '{ print $2 }'`

wget http://nordx-server/workstations.csv

CSVLINE=`grep $MAC workstations.csv`

NEWNAME=`echo $CSVLINE | awk -F ',' '{ print $2 }'`

CLASSROOM=`echo $CSVLINE | awk -F ',' '{ print $3 }'`

WORKSTATION=`echo $CSVLINE | awk -F ',' '{ print $4 }'`

rm workstations.csv

We're wgeting the workstations.csv file from the server and then, as the comment says, we're finding out what workstations we're running on by greping for our MAC address. Then we're putting the relevant information into three variables that we can then use to figure out what needs to be done at this workstation: $NEWNAME, $CLASSROOM, and $WORKSTATION. Now, using those variables and a little bit of bash-jitsu, we can configure the workstations however we need.

So, in human language, what's happening?

Every time that a workstation is imaged or updated using SystemImager the workstation is brought back to its pristine proto-form, except for any directories such as the teacher and student home directories, as well as the iTALC private teacher key, that are specified in /etc/systemimager/updateclient.local.exclude.


  • The image wakes up in its new body, it notices that the time has come so it unleashes the autoconfig script.
  • The script reconfigures the workstation into its desired form, and then shuts the computer down.

To make a long story short: After you set this up to your liking, your workstations will configure themselves whenever they need to so you won't have to do it for them.

Powered by ScribeFire.


Anonymous Anonymous said...

Nice. I've saved the last few posts and hope to be able to use SystemImager when we make our next image. I'm currently doing scp through a for script to push customized files to each client. It works, but it's a bit tedious to have to type (or paste...) the password 90 times. This is exactly what we've needed. Thanks again!

By the way, are you planning on continuing your blog after starting the new job?

8:13:00 AM  
Blogger Simón A. Ruiz said...

Right on, well, I'm glad to be of help; if you have any questions, you know where to find me.

And yeah, the blog'll stay right here and active; I'll be changing the title--since I'll no longer BE @ BHSN--but the URL will stay the same. I'll be working on Ubuntu in a similar, but expanded context in my new job; Canterbury has followed the Indiana ACCESS plan to create a 1:1 classroom.

9:32:00 AM  

Post a Comment

Links to this post:

Create a Link

<< Home