EdubuntuClassroomLogoff

Creating a simple logoff script to logoff an entire class at once

I'm simply taking a little time here to document a time-saving tip that I have used for a few years in my own school. I've written a script which kills users and their processes thus effectively logging them out of the server. This script has saved my sanity with my kindergarten classes...especially early in the school year. Even with simple passwords and usernames, very young children who do not know how to read or write yet can find it pretty challenging to log in and out of a computer. Logging in is a skill we spend quite a bit of time on, but I've discovered that an engaged youngster is difficult to pry away from the computer...much less be able to get them all logged off, lined up, and ready for the next class. I've found that logging the kids off "en masse" works best for me. At the end of the class...I announce that it's time to go...and then click an icon on my desktop that logs all the kids off. Here's how I did it. YMMV

First let's create the "killdead" script

Open your favorite text editor and paste the following. Save it with the name "killdead".

if [ "$1" = "root" ]; then
   echo "Can't kill root"
   exit
fi

pkill -9 -u "$1"

Be sure to make the file executable...

chmod a+x killdead

Copy "killdead" to /usr/bin (you may want to keep a copy in your own home folder as well)

cp killdead /usr/bin

killdead can now be used to simply "kill" a user and their associated processes Usage: killdead username

killdead username

Now let's get things organized so we can kill a whole bunch of users!

Now, I'm going to organize things here in a way that makes sense to me, but since this is Open Source...feel free to do it your own way. Just be sure to change the paths in your files. Ok...here we go.

First, let's create a directory for housing our files. I did most of my work in /root, but you can work in any administrators /home directory. Go to the directory you'll be working from.

mkdir stop-classes

cd stop-classes

Now, let's make the "killgroups" file. Open your favorite editor and paste the follwing...

cat $1 |while read LINE
do
echo "Processing $LINE"
sudo killdead $LINE
done

Save the file as "killgroups". Be sure to make the file executable.

chmod a+x killgroups

Next we need to create the file that will invoke "killgroups" and read the class list from which you'll be logging off or killing the users. Open your editor and paste the following. Change "ClassList" to a filename of your choosing.

cd /root/stop-classes
. killgroups ClassList

Save this file with a name you'll remember well. I used "Logoff-Class", substituting "Class" with a name of a particular teacher...example: Logoff-Jones

Be sure to make your file executable.

chmod a+x Logoff-Class

Now it's time to create the list from which the names will be read

This file is a simple text file with a list of usernames in a particular class. Here's an example:

jmantha
mzimmerman
dtrask
rweiderman
ograwert
jkronebusch
sruiz
mshuttleworth
moquist
jmcquillan
sbalnaeves
eharrison

Save this file with the name you used when creating the Logoff-Class script. In my example I used "ClassList"....feel free to use a more meaningful name, just be sure to match whatever you used in the file above.

Now you can run it!

. Logoff-Class (or whatever name you chose)

You can also easily create Launchers to be able to run this by clicking an icon. Create multiple instances of the script for each different class.

You can add certain classroom teachers to the sudoers file with permission to execute this script.

If you run multiple Edubuntu servers like I do...you can use something like "fanout" to execute the script on multiple servers at once. I will document this in a few days.

EdubuntuClassroomLogoff (last edited 2008-08-06 16:39:56 by localhost)