|
Thu, Aug 03, 2006
Rube Goldberg
I'm building a service to handle gathering and presenting
data for Capacity Planning. So far, I've built the data
gathering scripts, the database loaders and the database
schema. I was working on the installer programs for client
machines when I needed a little help solving a problem and
reached out to a mailing list and a shareware author.
The problem is generating a MacOS X installer Disk Image
(DMG) file using customized files for each client that signs
up for the service. I built a command line script for doing
this and got it working fine from my own user account. The
problem started when I tried to make the signup program
running on the web server call my DMG creation script.
Basically, the installer script needs to be called from a
user that is logged in to the system, which isn't the case
for the user running as the web server. A couple of the
commands in the script need to access the Mac desktop.
I looked into a couple 3rd party applications, namely DropDMG,
which includes CLI and GUI versions and is shareware at $15 with
30 days fully functional trial. Unfortunately, it had similar
problems, it ran just fine from the command line, but not from the
webserver or cron. I emailed the author and he suggested trying
setuid with the CLI or trying it via cron, but said I will likely
need to have a user logged in to use it. I went down both those
paths and didn't have any luck.
So, what I ended up doing was building a simple shell script of the
commands I needed within the CGI program, then writing out a file
with those commands into a specific folder. I then attached a Folder
Action to the folder and lifted most of what I needed from an
Apple-supplied AppleScript. The Folder Action monitors the folder,
sees a new file added to it, launches the AppleScript, which includes
a "do shell script" command in it. That do shell script reads the
file[s] in the Folder Actions directory and processes the commands
in them. One of those commands is the DropDMG command necessary to
build the .dmg file and put it in the appropriate place.
Executive Summary: CGI -> shell script -> Folder Action -> AppleScript
-> shell script -> DropDMG -> .dmg file
I'm going to contact Rube Goldberg to document the process a little
more cleanly.
|