Article:
 |
|
Start Me Up: Writing and Understanding OS X StartupItems
|
| Subject: |
|
RunService |
| Date: |
|
2003-10-24 16:01:40 |
| From: |
|
anonymous2
|
|
|
|
A minor nit.. but I don't believe the following statement is quite correct:
"When called with a single argument, RunService will run the function named "Argument"Service. For instance if you were to execute:
RunService "go";
it would execute the function named "GoService". "
If you look at the RunService function found in /etc/rc.common you'll find that it's actually a case statement that specifically looks for the arguments "start", "stop" or "restart" and then calls "StartService", "StopService" or "RestartService" respectively. Any other parameter will be treated as an unknown argument.
So you can't arbitrarily set up any function name (say "FooService") in your startup script and expect
RunService "Foo"
to call it.
Steve
|
Showing messages 1 through 2 of 2.
-
"RunService" not available on Mac OS 10.1
2004-02-04 14:21:06
smithkennedy
[Reply | View]
I would also like to add that the "RunService" shell script function is not implemented in rc.common on Mac OS 10.1.x, so if you do need to support that version of Mac OS X, you should keep this in mind. You can do a test to see if RunService is in /etc/rc.common, and switch on that, like so:
FOUND_RUN_SERVICE=`grep -c RunService /etc/rc.common`
if [ ${FOUND_RUN_SERVICE} -a ${FOUND_RUN_SERVICE} -eq 1 ]; then
RunService $1
else
StartService
fi
Also, make sure your property list file is the old NeXT-style instead of the newer XML .plist file format(s). SystemStarter will crash if it hits one of these newer .plist files.