Once you have testing your nFoldMonOnly configuration manually, you will probably want to automate its startup so that it is always running. There are a number of ways to do this. Here are two suggestions: one easy and a bit ugly, one hard and elegant.
The easy way to start something automatically is, of course, to set it up as a "Login Item" startup:

Unfortunately, only Applications can be made into login Startup Items, and nFoldMonOnly is not an application, it is a unix process. The solution is to have a little mini-application that does nothing except run nFoldMonOnly.
Such a mini-application is provided with nFoldMonOnly. It is a text file called "nFoldManLoginItem.command". The ".command" suffix tells Mac OS X that it is a script written in Unix shell script language, that should be run when it is double-clicked.
To set up a Login Item using this shell:

When you log in, the command will run, and will leave nFoldMonOnly running.
Unfortunately, running a command this way opens a Terminal window and leaves it open, which is a bit messy. See below for a neater technique.
A neater way to automate the startup of a Unix task is to set it up as a system StartupItems script. This technique has advantages and disadvantages:
Advantages |
Disadvantages |
|---|---|
|
|
StartupItems are a built-in feature of Mac OS X. They are used by the system and by commercial software to launch various background processes at system boot time or user login time. If you're not already familiar with the concepts behind StartupItems, there are a number of good introductory articles on the Internet. One good one is here at MacDevCenter .
A StartupItem is a set of files in a directory. The directory can be in one of 3 locations:
| your-user-id/Library/StartupItems | StartupItems placed here will be run when you log in. |
| /Library/StartupItems | StartupItems placed here will be run when the system boots, even before anyone logs in (a great way to keep your folding task active all the time). |
| /System/Library/StartupItems | Like /Library/StartupItems but reserved for System use - may not survive an OS upgrade. |
I suggest putting your StartupItem in /Library/StartupItems so it will run even when no one is logged in, unless you really want to restrict the action to just one of the authorized users. For the rest of this discussion, we'll use /Library/StartupItems as our location.
Your StartupItem will consist of a directory inside the /Library/StartupItems directory. Let's assume the directory name will be "nFoldMonOnly". Inside that directory there must be two text files, one called "StartupParameters.plist" and one called exactly the same name as the directory -- "nFoldMonOnly" in this case.
The "StartupParameters.plist" file tells the Mac startup management system some basic information about the task you are defining, such as what to call it in the login status window. More important it tells it when in the Mac boot sequence this startup should be run.
The sample file that came with nFoldMonOnly looks like this:
{
Description = "nFoldMan Monitor Only";
Provides = ("Folding");
Requires = ("Network", "Disks");
OrderPreference = "Last";
}
The "Requires" and "OrderPreference" lines say that this process should be among the last things started during the boot process, and that it must not be started until the network and disk systems are available.
The other file in the directory must have the same name as the directory -- "nFoldMonOnly" in this example. It is an executable script that will be run during the system startup sequence.
The sample file that came with nFoldMonOnly (which you will need to edit) looks like this:
# The following line runs the standard startup script stuff supplied by Mac OS . /etc/rc.common
# Put a message in the startup window
ConsoleMessage "Starting nFoldMonOnly monitor"
# Leave the following 2 commands on one line # Replace PATH with the absolute path to the directory containing the nFoldMonOnly program # Replace YOURUSER with the userid under which you want to run your folding. This will normally # be your primary userid. Don't use "root" -- you don't want nFoldMonOnly, or the folding # client, running as root. It's not good practice to let any software you got from a # stranger (like me) run as root on your system.
cd PATH; su YOURUSER -c "./nFoldMonOnly ./textControlFile.txt" >console &
(Actually the file is somewhat longer than this, as it has more comments in it, but this will give you the idea.)
You should edit this file and make 3 changes:
Warning: StartupItems are executed by the system during startup, so they run in root status. It is very dangerous to let software written by a stranger run in root mode on your system. You shouldn't trust me or the authors at Stanford to do this.
That's what the "su" command at the bottom of the script above is for. It runs the nFoldMonOnly program as your regular userid, not as root, so it won't have any special privileges. And when it launches the folding client, it also will run as you, without special privileges.
Now some finicky details. The system tries to protect you from authoring StartupItem scripts if you don't know what you're doing. So, the StartupItem will not run unless several conditions are met. (I'm going to assume you know how to use the Unix commands mentioned below. If not, look them up in the "man" command, or see the StartupItems tutorial mentioned above.)
Restart your computer. Carefully watch the startup window and you should see the messages listed above go by. After your startup completes, you should find (using Activity Monitor) that nFoldMonOnly is running in the background, owned by your normal userid. If it isn't, something in the above steps wasn't done exactly right -- go through the instructions carefully.