9 Dec 2004 chalst   » (Master)

Just written a shell script for reclobbering resolv.conf files mangled by dhclient that has created an enormous sense of relief for me:
#suclob-resolv: written Charles Stewart (C) 2004
file="$1"; test -z "$file" && file=${HOME}/doc/dns/resolv-wv-fhd.conf
grep -e "^nameserver " "$file" || \
    (echo "$file" does not appear to name any nameservers; exit 1)
set -x
super cp "$file" /etc/resolv.conf
No, it won't work for you as is, it's just a personal hack. The point? Well, maybe the super command isn't well known to people who chance upon this diary snippet: it's a much better alternative to sudo that is popular amongst FreeBSD types: I recommend you take a look (it's in Debian, as well)

Postscript #1: yeupou asks: why not simply editing dhclient.conf so it does not mangle your resolv.conf in an annoying way?
Some reasons: I've read the resolv.conf man page several times and didn't know you could configure this; even now I know, I expect writing the script was faster and easier than figuring out the right way to configure the cf file; possibly resolv.conf needs to clobber the file to work properly; the script I wrote solves a problem in addition to anti-clobbering one, namely a by providng a sort of wvdial localisation support.

Postscript #2: xach notes a dumb error in an earlier version of the above script: I had used a shell-style glob syntax in the -e argument to grep. Script corrected: I dropped the idea of filtering for the presence of a dotted quad: it's a mistake in any case, since one wants to see even lines that don't conform. Thanks to xach for the tip.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!