Skip to content

Instantly share code, notes, and snippets.

@kghose
Created August 1, 2011 23:06
Show Gist options
  • Save kghose/1119206 to your computer and use it in GitHub Desktop.
Save kghose/1119206 to your computer and use it in GitHub Desktop.
Mac OS X StartupItem script (can be generalized)
#!/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"
@kghose
Copy link
Author

kghose commented Aug 1, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment