Startup items are directory bundles which contain, at a minimum, an executable file and a property list text file. For a startup item named "Foo", the bundle will be a directory named "Foo" containing (at a minimum) an executable "Foo" and a plist file "StartupParameters.plist".
mkdir /Library/StartupItems/Greeting
#!/bin/sh
##
# Do my Greeting
##
. /etc/rc.common
if [ "${FIREWALL:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Adding Firewall Rules"
ipdeny=`cat /Documents/Firewall/Firewall.deny | sort | uniq`
ipallow=`cat /Documents/Firewall/Firewall.allow | sort | uniq`
# allow first
counter=2000
for i in ${ipallow}; do
ipfw add $counter allow all from $i to any
counter=`expr $counter + 1`
done
# deny second
counter=`expr $counter + 1000`
for i in ${ipdeny}; do
ipfw add $counter deny all from $i to any
counter=`expr $counter + 1`
done
fi
"chmod +x Greeting" the shell script file
{
Description = "HAL9000 greeting";
Provides = ("Greeting");
OrderPreference = "Last";
Messages =
{
start = "speaking greeting";
stop = "greeting going away";
};
}
The above example is written in the old NeXT-style property list format for
compactness. But the new XML property lists are also handled.
You may prefer using PropertyListEditor.app to editing the property list files manually.
The plist file contains parameters which tell SystemStarter some information about the executable, such as what services is provides, which services are prerequisites to its use, and so on. The plist contains the following attributes: Description, Provides, OrderPreference, etc.
Startup items may be placed in the "Library" subdirectory of the primary file domains ("System", "Local", and "Network"). The search order is defined by routines defined in NSSystemDirectories.h: Local, then Network, then System. However, because the Network mounts have not been established at the beginning of system startup, bundles in /Network is currently not searched.