Thursday, June 15, 2006

Starting a Service (Zebedee)

In the previous article, I talked about launchd and plists. The reason I investigated all of this is that I needed to start the zebedee service at boot time. Zebedee is an easy-to-use tool for setting up encrypted tunnels. In this case, I wanted to create an encrypted tunnel to the OS X machine's VNC server. (Although VNC encrypts the initial password exchange, all other traffic is left unencrypted.) Zebedee isn't specific to OS X. We've used it for a long time on Windows and Linux computers.

After installing zebedee, I created the following plist file, which I name org.zebedee.zebedee.plist, conforming to the naming conventions used for other plist files:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.zebedee.zebedee</string>
<key>ProgramArguments</key>
<array>
<string>/common/bin/zebedee</string>
<string>-s</string>
<string>-f</string>
<string>/local/etc/server.zbd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/zebedee.log</string>

</dict>
</plist>

The idea is to execute the command "zebedee -s -f /local/etc/server.zbd". The only plist elements I use are:

  • ProgramArguments, which specifies the program name and any command-line arguments, one item at a time
  • RunAtLoad, which says that the program should be run when the plist file is loaded by launchd. (Launchd has the ability, like xinetd, to bind to a port and listen for incoming connections, then start up an appropriate program on-demand. I'm not doing it that way here.)
  • StandardErrorPath, which specifies the name of the log file to which the programs stderr output should be sent.
I can then start the program by hand by typing "launchctl load org.zebedee.zebedee.plist". Checking with 'ps auxwww | grep zebedee" shows
root 2521   0.0  0.0    27528    180  ??  Ss   12:12PM   0:00.00 /common/bin/zebedee -s -f /local/etc/server.zbd

I then copied the file org.zebedee.zebedee.plist into /Library/LaunchDaemons/ and rebooted. The zebedee service was automatically started during the reboot.

No comments: