Creating a system starter entry on MacOSX
Posted 2009-06-10 12:26:36 by .

I built my own version of Apache on my mac. I wanted my Mac to use this after I disabled the default Apache that comes with OSX. To do this I needed to create a SystemStarter entry. This was a fairly straight forward process. The end result was Apache persisting across machine reboots.

References

 

Creating a system starter entry

1. Create a folder in /Library/StartupItems.

 
sudo mkdir /Library/StartupItems/OisinApache


2. Create an executable script with the same name as the folder.

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
sudo vi /Library/StartupItems/OisinApache/OisinApache

#!/bin/sh
. /etc/rc.common

# The start subroutine
StartService() {
ConsoleMessage "OisinApache: starting apache (/opt/web/bin/httpd)"
/opt/web/bin/httpd -f /opt/web/conf/httpd.conf
ConsoleMessage "OisinApache: running."
}

# The stop subroutine
StopService() {
ConsoleMessage "OisinApache: Stopping apache (killall httpd)"
killall httpd
ConsoleMessage "OisinApache: stopped."
}

# The restart subroutine
RestartService() {
ConsoleMessage "OisinApache: restarting apache (/opt/web/bin/httpd)"
StopService
sleep 1
StartService
ConsoleMessage "OisinApache: restarted."
}


3.Create a StartupParamets.plist in the same place as the executable script.

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sudo vi /Library/StartupItems/OisinApache/StartupParamets.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>Description</key>
<string>Oisin's Compile Apache</string>

<key>OrderPreference</key>
<string>Late</string>

<key>Provides</key>
<array>
<string>OisinApache</string>
</array>

<key>Uses</key>
<array>
<string>SystemLog</string>
</array>
</dict>
</plist>
}}}


4. Done! If you followed the above you can now use the following command line to start, stop or restart apache.

 
sudo SystemStarter {start | stop | restart} OisinApache


 

Comments

No Comments. Be the first to add one.

New Comment

Your email is never published nor shared.
Required fields are marked *
*
*