d-i work...

How did I forget to brag about recent d-i fun / bore everyone in the world to tears? That will never do.

Let's see. One fun thing I did recently for d-i was write a web server in 56 lines of posix shell (+ netcat). I also wrote a mail program that can send email direct to outgoing nntp servers in a couple dozen lines of shell, but it was unbrearably buggy and I threw it away.

The reason for these is that it can be very useful in debugging d-i to get at the log files of a failed d-i run, but the only way d-i supported to do it before was to save them to floppy. Now it offers this nice option to start a web server and if I'm lucky I can just browse the running installer until I find the problem.

One of the little pleasures of d-i is being able to do stuff like write a web server in shell without it being a pointless exersise or Not Invented Here syndrome. (I did search for web servers in shell first, but didn't find one; all the small web servers in C are still a bit larger, and compile to bigger binaries; busybox doesn't seem to include a web server .. yet.)

Besides having to read all the http RFCs, which I've not looked at since circa 1995, and work out how to speak the simplest http varient I could (1.0) while pretty much working with all web browsers, the only really interesting bit was this, which comes after it's read the first GET line from the client:

# Reading the rest of the client's request is important; clients tend to get
# confused otherwise. Junk it all..
while read xx ; do
        test "${xx}" || break
        test "${xx}" = "" && break
done

Without this mozilla loses a random chunk of the end of the file and doesn't seem to notice or care; wget loops repeatedly.