Free Software Written by Nick Urbanik
I have written a number of programs over the years to help with system administration and anything else I need to do. Here are just a few of them.
We have had problems with ISC DHCP in failover mode when the
size of the
dhcpd.leases file was in the order of
250 MB or so. Every hour, the ISC dhcp server stops to dump
all its leases to a new
dhcpd.leases file, during
which time, it enters "Communications-Interrupted" mode. About
once a week, the two machines would fail to re-establish normal
communication. This caused much consternation and phones rang
under pillows at 2 AM.
A colleague of mine had "a very cunning plan" to solve this problem. I coded up a patch, which is licenced under the GPL of course. I also wrote a program in Perl to aggregate the dhcpd.leases files.
The basic idea of this is that the DHCP server never stops to rewrite its leases files; the external process, dhcp-aggregator.pl does that instead.
Please note that you may wish to change the value
$START_DIR, the location of of the dhcpd.leases
/var/lib/dhcpd (or something else)
Updates to Next File Patch
This version fixes two bugs:
counting = 1;fix
- The patch previous to this had a serious omission that
dhcpdfrom starting a new
dhcpd.leasesfile every hour. That has been fixed with a one-line addition to the code.
- Locking during startup
- This allows
program performing the aggregation to know
dhcpdis in its startup phase, so that it knows when not to rename the old lease files.
flock(8)s a lock file during its startup, and the external program cooperatively does not rename the old files until this lock is released.
Updates to dhcp-aggregator
It also fixes a bug that would allow another dhcp-aggregator process to start while the previous dhcp-aggregator process was waiting for a lock.
reads the leases from the
configuration file to determine whether a lease remains within
one of the ranges of IP addresses. If it does not, the lease is
removed during the aggregation process.
Used by several hundred thousand customers
This code is currently serving several hundred thousand happy cable customers, so it may serve your purposes.
Hope for patch to be incorporated in ISC DHCP server
It is my hope that the ISC will incorporate this patch into the official ISC DHCP server, and I am happy to cooperate to improve it, and would like to hear any suggestions for its improvement.
Chroot a Program
Sometimes you want to chroot a program. It's a nuisance to put all the required libraries into the chroot. Here's a little simple minded program that will take care of most of the boring details.
With any of these programs, if they nearly but not quite do what you want, write to me, and I'll (probably) make it do that.
CA and Certificate Creation
The convenience of using your own long-lasting root CA certificate and distributing that to your customers compared with giving them a copy of a self-signed certificate is that you only need to give them the root certificate every decade.
Another benefit is that you do not have an outage while the local self-signed certificate does not match that held by the customer. The upgrade needs to be simultaneous to avoid that outage.
To that end, I wrote make-new-ca.pl and make-server-cert.pl to help automate this process. I know that the CA.pl script with openssl is designed to help, but I wanted something that makes it even more straight forward.
LDAP Directory Management
When working with
slurpd, I wanted to have a simple
way to produce diffs bwtween two LDIF entries that would be
suitable for feeding to
ldapmodify, so I
ldap-diff that produces
such LDIF output. The first version of this program loads
everything into memory, but handles DNs properly even if they
are wrapped over more than one line.
At the Department of Information and Communications Technology at the Hong Kong Institute of Vocational Education (Tsing Yi) I implemented a single sign on solution for our full-time and part-time students and staff. Here are some of the programs I wrote to manage this.
- manage-directory.pl is my re-write of the first program to manage the directory from the student records. This is a command-line program to read the student record files, and directly generate the POSIX accounts. It can also delete accounts given student records.
- migrate-users this is the first program I wrote to maintain the directory.
- gen-acls.pl — a program to generate access control lists for the directory
- mail-people.pl — A program to fill in form email letters using information from the directory, selected with an LDAP filter.
- setup-ldap1.pl — Create a set of LDAP directories where management of each directory is assigned to one person.
DHCP and DNS Management System
Please see a detailed description of this system. It combines Perl programs, Samba, DHCP, BIND and some shell scripts to create a simple way to keep track of computers, and maintain network information and configuration for those computers.
Copy podcasts to music player
Maintain Apache Password File from Mailman Addresses and Passwords
It would be nice to use the usernames and passwords from a
Mailman mailing list to control access to a web site. I
mm_htaccess to do that. I based this
on a collection of shell scripts, a Makefile builder, and other
the Mailman FAQ and thought I might do it simpler. It can
also send this file by ftp to a remote server if required.
Inspired by the example eg/hrefsub
I have written
which munges all the links, including those in comments (for
recalcitrant IE) and those in
url(...)</script>, as well as with Apache SSI
includes. It's very much oriented to what I want, but then, so is
GnuCash XML File Munging
Tired of trying to get GnuCash to generate reports that are
useful to me, I decided to write
an GnuCash XML munger. What I
wanted was really simple, and so
actually does is very simple too; it simply gives the amount for
each account over any period of time.
catting a file
Needing to simulate how a dhcp server writes its lease files, I
which divides its input files into a specified number of random
pieces, then writes them to standard output with random delays.
Generating Type Map Files for Apache Content Negotiation
When writing strict xhtml web pages such as this one, it is nice to serve it as application/xhtml+xml to web browsers that Accept it. This is called content negotiation. Apache provides two methods to do this:
- using Multiviews, where Apache looks for all files that start with the name provided in the URL,
- Using Type Maps.
Since type maps are slightly more efficient, and give more control over the content negotiation, I decided to write a program gen-type-map.pl to implement type maps automatically for each named file.
Note that if you view this page with Firefox, and select Tools => Page Info, you will see that the Content type is application/xhtml+xml, while Internet Explorer will get text/html.
Online man page viewer
I needed a simple way to present documentation for system
configuration and system commands, so I wrote a simple cgi
man to allow reading man
pages over a web browser. Look up the man page for the Apache::AuthNetLDAP
module to which I contributed.
Editing Large numbers of Web Pages
Rotating Mail Folders
When subscribing to many mailing lists, they can easily grow to the point where mutt slows down a bit when opening the folder. I wrote a program rotate-mail-folders.pl to run from cron to rotate them when they reached a suitable size.
Generate Quiz questions in Moodle
Moodle is an open source learning system used for education and training systems around the world. I wrote this program to convert questions in one common format to one that Moodle can import simply.
Noughts and Crosses
I wrote this game noughts-and-crosses.pl to play with my son.
Make Phonogram Cards
Make Arithmetic Exercise Sheets
When our child was in kindergarten, I wrote make-sums.pl to generate sheets of arithmetic exercises for him.
Calculate volume, weight of sand, cement and gravel to mix volume of concrete
I've mixed a bit of concrete lately, and prefer to buy the right amount of sand, cement and gravel to mix it, since it is a nuisance having too much left over. So I wrote a little program to calculate the correct volumes and weights of sand, cement and gravel for a required volume of concrete: calc-concrete.pl
Examine and Change EXIF Data in Photographs
When rotating JPEG images lossleesly with gthumb, the mtime date stamp is changed. I wrote three little programs:
- exif-data.pl to view all the exif data,
- exif-timestamp-show.pl to show the current exif timestamps,
- exif-timestamp-adjust.pl to adjust the mtime timestamp to match the time the photo was taken, going by the exif data.
Generate Web Pages Given A Directory Of Photos
This started because I was very busy after my son was born, and we took zillions of photos, and I just wanted any family member to be able to just plug the cable into the camera and for the photos to be automatically downloaded, sorted into directories, and a web page made for each day, showing thumbnails of all the photos.
- gallery-ed — run automatically, or manually, or as part of a web application, to generate the web pages.
Limit Time A User Spends Running Particular Software
We decided to limit the time my son spends playing computer games each day. This set of programs implements control on games that he can play. After time is up, then games in the group whose time has expired will be killed in less than thirty seconds.
His ambition is to be able to write a more powerful program to beat this program. I'm sure he will succeed one day.
- limit-time-on-games-db.pl — This is the daemon program that starts when the system boots. It runs on all the computers that the user may run the programs on.
- change-game-limits.sh — run from the crontab of the user that owns the database
- change-game-time-left.sh — allows convenient changing of time left before the games start being killed
- time-left.pl — a simple tcl program to let the user find out how much time they have left.
- README — includes basic instructions for setting the system up.
Count Number Of Elements In Training Packages
When doing the Certificate 4 in Workplace Training and Assessement for TAFE teaching, there is an assignment that involves assessing someone on their competency in some particular skill that is listed among the thousands on the website http://www.ntis.gov.au/. So I decided to automate selecting the optimal training packages by reading them all and looking for the minimum number of elements. Hence count-elements-in-training-packages.pl.
Make a Convenient Phone Book Sheet From Abook Database
I like abook, since it can be integrated with my mutt email client, and so decided to write software to produce a nice sheet oc paper that I can glue into my diary containing contact information that matters to me.
- make-address-book.pl — the Perl program that does the work
- address-book — a small shell script wrapper
- address-book-header.tex — Provides the LATEX template that comes before the output of the program
- address-book-footer.tex— Provides the LATEX template that comes after the output of the program
Convert Between Time Zones, include Daylight Saving
It is often important to check the time in another timezone:
when is it too late to phone my friend in France? What time will
the Fedora Core 6 release be made? It is often a problem to think
about daylight saving. It would be nice for the computer to use
its own time zone database to work all that out for me. I wrote a
little program to solve this little
Get My IP Address
A simple shell script to show the IP address of the interface
connected to the default gateway by parsing the output of
Licenses of the Software
All the software written by me, linked to on this machine from this page, is is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.