Date: 2004-12-05T10:17:54
   Editor: MattBishop <[EMAIL PROTECTED]>
   Wiki: Apache James Wiki
   Page: RunAsService
   URL: http://wiki.apache.org/james/RunAsService

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,10 +1,10 @@
-For Linux I know of two ways to do it.  
+For Linux I know of two ways to do it.  (Instructions for Mac OS X are below.)
 
-For Red Hat there are these instructions; 
http://www.ejbsolutions.com/products/obox/community/ch20.html. These worked on 
Red Hat for me easily. However I think the wrapper method below is probably 
more recommended as it almost "out of the box" functionality with James.  For 
Debian - I found the Red Hat instructions above didn't work straight away.  So 
I used the wrapper" instructions on my Debian box, which turned out to be 
''much'' simpler.  
+For Red Hat there are these instructions; 
http://www.ejbsolutions.com/products/obox/community/ch20.html. These worked on 
Red Hat for me easily. However I think the wrapper method below is probably 
more recommended as it almost "out of the box" functionality with James.  For 
Debian - I found the Red Hat instructions above didn't work straight away.  So 
I used the wrapper" instructions on my Debian box, which turned out to be 
''much'' simpler.
 
 '' Wrapper Instructions ''
 
-The wrapper instructions are found at 
http://wrapper.tanukisoftware.org/doc/english/launch-nix-boot-debian.html 
+The wrapper instructions are found at 
http://wrapper.tanukisoftware.org/doc/english/launch-nix-boot-debian.html
 
 I had to edit phoenix.sh to set the PHOENIX_HOME (somewhere near the top)
 
@@ -36,7 +36,7 @@
  #!/bin/sh
  # description: JAMES Mail Server
  # chkconfig: 2345 99 00
- 
+
  case "$1" in
  'start')
          /home/james/james/bin/phoenix.sh start
@@ -53,7 +53,7 @@
  exit 0
 }}}
 
-Alternatively, if you've got webmin installed, go to the system section and 
select "Bootup and Shutdown". Near the top of the page you'll see a link to 
create a new bootup and shutdown action. You can use that to create a service 
that's run at startup and shutdown. Just specify the comand: 
+Alternatively, if you've got webmin installed, go to the system section and 
select "Bootup and Shutdown". Near the top of the page you'll see a link to 
create a new bootup and shutdown action. You can use that to create a service 
that's run at startup and shutdown. Just specify the comand:
 
 {{{
  /home/james/james/bin/phoenix.sh start
@@ -65,16 +65,112 @@
  /home/james/james/bin/phoenix.sh stop
 }}}
 
-That should be it. You can test it by running 
+That should be it. You can test it by running
 
 {{{
  /etc/rc.d/init.d/james start
 }}}
 
-to start and 
+to start and
 
 {{{
  /etc/rc.d/init.d/james start
 }}}
 
 to stop it.
+
+'''Mac OS X'''
+
+These instructions work on Mac OS X 10.2 and 10.3.  I haven't tested them on 
10.1.
+
+''Install James''
+Most OS X services like James are stored in /Library, so a good place to store 
it would be /Library/James.  You may want to follow the advice of storing the 
distro in /Library/James/james-2.x and then creating a soft link to it with 
this command:
+
+{{{
+ ln -s /Library/James/james-2.x /Library/James/Home
+}}}
+
+This creates the path /Library/James/Home, which leads you to the james-2.x 
directory.  When a new version comes out, simply install james-3.x in 
/Library/James, delete the Home link and recreate it with the above command so 
that it points to james-3.x.  This will save you from having to edit the 
startup scripts later.
+
+''StartupItems''
+Mac OS X looks in /Library/StartupItems for services to start up at boot time. 
 Go to this directory, and create it if it's not already there.  Inside this 
dir, create another one named 'James'.  The spelling and capitalization are 
important.
+
+Next, create these two files in /Library/StartupItems/James:
+
+''StartupParameters.plist''
+
+{{{
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+<plist version="1.0">
+<dict>
+  <key>Description</key>
+  <string>Apache James Mail Server</string>
+    <key>Messages</key>
+    <dict>
+      <key>start</key>
+      <string>Starting Apache James Mail Server</string>
+      <key>stop</key>
+      <string>Stopping Apache James Mail Server</string>
+    </dict>
+    <key>OrderPreference</key>
+    <string>Last</string>
+    <key>Provides</key>
+    <array>
+      <string>James</string>
+    </array>
+    <key>Requires</key>
+    <array>
+      <string>Resolver</string>
+    </array>
+  </dict>
+</plist>
+}}}
+
+These preferences provide the OS with hints as to when James should be 
started.  OS X 10.2 needs James to start at the end of the boot process, or 
very near the end, so the OrderPreference key provides this hint.  I am not 
sure what other service James depends on that requires this key, but this 
solved the problem for 10.2.  OS X 10.3 doesn't need it to start last, so if 
you need James to start earlier for some reason, you can set it to None.
+
+''James''
+
+{{{
+#!/bin/sh
+
+##
+# Apache James Mail Server
+##
+
+. /etc/rc.common
+
+StartService ()
+{
+    ConsoleMessage "Starting Apache James Mail Server"
+    sudo sh ${PHOENIX_HOME}/bin/phoenix.sh start
+    ConsoleMessage -S
+}
+
+StopService ()
+{
+    ConsoleMessage "Stopping Apache James Mail Server"
+    sudo sh ${PHOENIX_HOME}/bin/phoenix.sh stop
+    ConsoleMessage -S
+}
+
+RestartService ()
+{
+    ConsoleMessage "Restarting Apache James Mail Server"
+    sudo sh ${PHOENIX_HOME}/bin/phoenix.sh restart
+    ConsoleMessage -S
+}
+
+export JAVA_HOME=/Library/Java/Home
+export PHOENIX_HOME=/Library/James/Home
+
+RunService "$1"
+}}}
+
+For 10.2, James needs to be started with the sudo command so that it will be 
allowed to open ports 110 and 25.  Also, this 'James' file needs to be marked 
as executable, which can be set with this command:
+
+{{{
+ chmod 755 /Library/StartupItems/James/James
+}}}
+
+You are now ready to restart your Mac OS X box and have James start up 
automatically.

Reply via email to