Student Control Panel Mods/Suggestions

Scott Balneaves sbalneav at legalaid.mb.ca
Fri Aug 3 04:08:28 BST 2007


On Thu, Aug 02, 2007 at 08:24:27AM -0500, Jim Kronebusch wrote:
> Second, in relation to scripting default printers by client location I would love to see
> a feature built in that allowed creation/building of groups.  I know that currently it
> has the ability to group users, but we could really use a feature to build groups by mac
> address.  If we could log in a lab of machines and simply select them from the left hand
> pane and create a new group called "High School Main Lab" for example, this would be a
> great start to easily implementing default printers based on location.   At first it
> would be great to simply be able to write this list to a text file somewhere to be used
> with scripting called by ldm.

I've seen some back and forth with the printers thing, and IMHO, this isn't really
part of LTSP.  The same way setting up desktop defaults really isn't part of LTSP
either.  Really, this should be part of the cups printing subsystem.

That having been said, assigning any kind of defaults based upon terminal MAC address
isn't that hard to do, and this recipe should be part of any good LTSP admins
bag of tricks.

Here's a simple little shellscript, called "returnbymac", or whatever you'd like.

#!/bin/sh

if [ "x$SSH_CLIENT" = "x" ] ; then
    IP=$(echo $DISPLAY | cut -d: -f1)
else
    IP=$(echo $SSH_CLIENT | cut -d' '  -f1)
fi

MAC=$(arp -na | grep $IP | cut -d' ' -f4)

VALUE=$(grep $MAC $1 | cut -d' ' -f2)

echo $VALUE

Note that this works in the ltsp environment because both the SSH_CLIENT variable and
the DISPLAY variable use the standard IP address of the client.

The first if/then/else sets the variable IP to the ip address of the terminal.  We
find the MAC address of the terminal by using the arp command, and get the mac from there

We obtain a value from a file passed in on the command line, from the mac address.

The file has the format:

#
# An example file mapping, lets say, MAC's to default printers
#

#
# Main lab
#

11:22:33:44:55:66 printer1
aa:bb:cc:dd:ee:ff printer1

#
# secondary lab
#

00:de:ad:be:ef:11 printer2


etc.


Save this file wherever you want, say /usr/local/etc/mactoprinter

Then, you can set up the LPDEST variable based on:

export LPDEST=$(returnbymac /usr/local/etc/mactoprinter)

You can see that by maintaining files of mac to <value> lists, you can easily set up
values based on anything you want.

Scott

-- 
Scott L. Balneaves | "Eternity is a very long time,
Systems Department |  especially towards the end."
Legal Aid Manitoba |    -- Woody Allen



More information about the edubuntu-users mailing list