CD Kiosk with CF, Mac OS X and Open Source Tools
A few years ago I was asked if I could build a kiosk application that would allow customers to select browser-based training courses from a menu and burn them to a CD. The CD had to contain a “scaffolding” of files and folders to make the courses run.
Now, I know there are several ways to do this in native languages. I wondered if it could be done in a web scripting language with a browser in kiosk mode as the front-end. The UI would be simple enough, just a database driven shopping cart of sorts with a little javascript to update the status of the burn process dynamically. The problem was how to setup, burn and eject the disc.
I looked for solutions on Linux at the time, but I didn’t find anything that would give me the kind of low-level interaction with the CD burner that I needed. OS X, on the other hand, has a cool command-line utility called drutil.
From the man page:
DESCRIPTION
drutil uses the DiscRecording framework to interact with attached burning
devices. Common verbs include burn, erase, eject, help, info, list,
status, and tray.The rest of the verbs are: bulkerase, cdtext, discinfo, dumpiso, dumpudf,
filename, getconfig, poll, subchannel, trackinfo, and version.
As you can see, this gave me excellent control via cfexecute. I just needed a way to actually burn via command-line, and view the output for feedback. Via Fink, I installed MkISOFS and CDRecord and had my full stack.
The customer would select the courses the wanted to burn, and “checkout”. The system would call drutil to open the tray and verify that media was inserted and it was writable. Then it would make a fresh copy of the base CD and copy the selected course files into the copy, in the proper locations. Via cfexecute I would have MkISOFS read the new folder and convert it to and ISO image – but I would pipe that output directly to CDRecord to avoid writing and reading to the drive again. That was much faster and since this was a kiosk and not a network app, I didn’t have to worry about concurrency.
As CDRecord writes, it outputs it’s progress to stdout which can be redirected to a file. I had CF “watch” the file and via a javascript I found on the MM developer exchange update a progress bar via cfflush. Today I would bind a div and pull the status via that fancy AJAX doojigger. Then drutil kicked out the finished disc and the UI reset.
Surprisingly, though this was really written as a proof of concept, it lasted almost 2 years and created hundreds of custom discs with only a few problems.
