Created
August 1, 2011 23:06
-
-
Save kghose/1119206 to your computer and use it in GitHub Desktop.
Mac OS X StartupItem script (can be generalized)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
# Diary service startup script | |
## | |
. /etc/rc.common | |
StartService () | |
{ | |
ConsoleMessage "Starting Diary" | |
cd /Users/kghose/Source/Jabda/ | |
/Library/Frameworks/Python.framework/Versions/2.6/bin/python pylog.py & | |
echo $! > jabda.pid | |
} | |
StopService () | |
{ | |
cd /Users/kghose/Source/Jabda/ | |
if pid=`cat jabda.pid`; then | |
ConsoleMessage "Stopping Diary" | |
kill -TERM "${pid}" | |
rm jabda.pid | |
else | |
ConsoleMessage "Diary not running" | |
fi | |
} | |
RestartService () | |
{ | |
ConsoleMessage "Restarting Diary" | |
StopService | |
StartService | |
} | |
RunService "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The StartupItems specification requires that the executable file has the same name as the subdirectory that contains it and that the executable is in the root level of subdirectory