<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Starting Postfix and Dovecot automatically on Leopard</title>
	<atom:link href="http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/feed/" rel="self" type="application/rss+xml" />
	<link>http://diymacserver.com</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 16:07:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Richard</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11248</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Tue, 19 Jul 2011 19:13:02 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11248</guid>
		<description>Iggie, thanks for your excellent input. I now understand it all a little better.</description>
		<content:encoded><![CDATA[<p>Iggie, thanks for your excellent input. I now understand it all a little better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iggie</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11240</link>
		<dc:creator>iggie</dc:creator>
		<pubDate>Tue, 19 Jul 2011 00:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11240</guid>
		<description>The reason the PID file is there is to make sure that only one server process is running.  If the master.pid file exists when dovecot starts up, you get an error like this in /var/log/mail.log:
master: Fatal: Dovecot is already running with PID 29 (read from /usr/local/var/run/dovecot/master.pid)

The existence of a PID file doesn&#039;t necessarily mean that such a process is actually running. Unfortunately, there is no portable way for dovecot to make sure that a process with that ID is actually executing and that this process is dovecot and not some other program.  So usually, its up to the startup scripts to ensure that the the pid file is not stale because these are specific for the OS.  Usually determining if a process with a given ID is associated with a named program is accomplished with some form of:
ps -ef &#124; grep $PID &#124; grep -v grep &#124; grep $PROGRAM

Its all moot anyway thanks to launchd, which does the same thing as the PID file madness is supposed to accomplish (run only one server at a time), but does it much better and also relaunches the server if it dies.  Since the script is meant to only run from launchd, and only on system start, its safe to remove the contents of the run folder.  In fact, this is exactly what RedHat&#039;s startup script does with dovecot.

Its probably slightly more well-behaved if only the master.pid file was removed by replacing this line
/bin/rm -f /usr/local/var/run/dovecot/* &gt; /dev/null 2&gt;&amp;1
with this line:
/bin/rm -f /usr/local/var/run/dovecot/master.pid &gt; /dev/null 2&gt;&amp;1
This leaves the /usr/local/var/run/dovecot/ directory in the same state as issuing the command:
sudo /usr/local/sbin/dovecot stop

Anyway, in case anyone wants to live (slightly!) dangerously, the script is fine left in the comments.
Thanks for assembling all of this info, by the way.  It was a tremendous help even for an old Unix hand like me.</description>
		<content:encoded><![CDATA[<p>The reason the PID file is there is to make sure that only one server process is running.  If the master.pid file exists when dovecot starts up, you get an error like this in /var/log/mail.log:<br />
master: Fatal: Dovecot is already running with PID 29 (read from /usr/local/var/run/dovecot/master.pid)</p>
<p>The existence of a PID file doesn&#8217;t necessarily mean that such a process is actually running. Unfortunately, there is no portable way for dovecot to make sure that a process with that ID is actually executing and that this process is dovecot and not some other program.  So usually, its up to the startup scripts to ensure that the the pid file is not stale because these are specific for the OS.  Usually determining if a process with a given ID is associated with a named program is accomplished with some form of:<br />
ps -ef | grep $PID | grep -v grep | grep $PROGRAM</p>
<p>Its all moot anyway thanks to launchd, which does the same thing as the PID file madness is supposed to accomplish (run only one server at a time), but does it much better and also relaunches the server if it dies.  Since the script is meant to only run from launchd, and only on system start, its safe to remove the contents of the run folder.  In fact, this is exactly what RedHat&#8217;s startup script does with dovecot.</p>
<p>Its probably slightly more well-behaved if only the master.pid file was removed by replacing this line<br />
/bin/rm -f /usr/local/var/run/dovecot/* &gt; /dev/null 2&gt;&amp;1<br />
with this line:<br />
/bin/rm -f /usr/local/var/run/dovecot/master.pid &gt; /dev/null 2&gt;&amp;1<br />
This leaves the /usr/local/var/run/dovecot/ directory in the same state as issuing the command:<br />
sudo /usr/local/sbin/dovecot stop</p>
<p>Anyway, in case anyone wants to live (slightly!) dangerously, the script is fine left in the comments.<br />
Thanks for assembling all of this info, by the way.  It was a tremendous help even for an old Unix hand like me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11203</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Sat, 16 Jul 2011 20:13:40 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11203</guid>
		<description>Iggie, I understand the problem you have but I don&#039;t like the script. The PID is there for a reason otherwise it would not have to be there. I can&#039;t really give you a reason yet, but it feels wrong….</description>
		<content:encoded><![CDATA[<p>Iggie, I understand the problem you have but I don&#8217;t like the script. The PID is there for a reason otherwise it would not have to be there. I can&#8217;t really give you a reason yet, but it feels wrong….</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iggie</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11198</link>
		<dc:creator>iggie</dc:creator>
		<pubDate>Sat, 16 Jul 2011 15:11:29 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11198</guid>
		<description>As configured above, the dovecot server will not restart after a forced reboot (e.g. power loss) due to a stale pid file in /usr/local/var/run/dovecot/master.pid.

My solution to this is to run a wrapper script from the launchd .plist instead of running dovecot directly:
save the text between &#039;-----&#039; to dovecot-wrapper.sh
-------
#!/bin/bash
# Wrapper script for starting dovecot at system startup
# Since this runs from launchd, any existing pid file is by definition stale

# ignore any error from doing this
/bin/rm -f /usr/local/var/run/dovecot/* &gt; /dev/null 2&gt;&amp;1

/usr/local/sbin/dovecot -F
------
copy the script to /usr/local/sbin/dovecot-wrapper.sh and set permissions:
sudo cp dovecot-wrapper.sh /usr/local/sbin/dovecot-wrapper.sh
sudo chmod a+x /usr/local/sbin/dovecot-wrapper.sh

Then, change the dovecot .plist above to run this script instead of dovecot by replacing &quot;/usr/local/sbin/dovecot&quot; with /usr/local/sbin/dovecot-wrapper.sh&quot;, and removing the subsequent line containing &quot;-F&quot; (since this option is in the wrapper).

Finally, reload the launchd .plist:
sudo launchctl unload /System/Library/LaunchDaemons/org.dovecot.plist
sudo launchctl load /System/Library/LaunchDaemons/org.dovecot.plist

The wrapper runs dovecot as a front-process (-F), so the script will keep running as long as dovecot is running, which keeps launchd happy.  Any command that kills dovecot will also terminate the script, which will cause launchd to relaunch it via the script.</description>
		<content:encoded><![CDATA[<p>As configured above, the dovecot server will not restart after a forced reboot (e.g. power loss) due to a stale pid file in /usr/local/var/run/dovecot/master.pid.</p>
<p>My solution to this is to run a wrapper script from the launchd .plist instead of running dovecot directly:<br />
save the text between &#8216;&#8212;&#8211;&#8217; to dovecot-wrapper.sh<br />
&#8212;&#8212;-<br />
#!/bin/bash<br />
# Wrapper script for starting dovecot at system startup<br />
# Since this runs from launchd, any existing pid file is by definition stale</p>
<p># ignore any error from doing this<br />
/bin/rm -f /usr/local/var/run/dovecot/* &gt; /dev/null 2&gt;&amp;1</p>
<p>/usr/local/sbin/dovecot -F<br />
&#8212;&#8212;<br />
copy the script to /usr/local/sbin/dovecot-wrapper.sh and set permissions:<br />
sudo cp dovecot-wrapper.sh /usr/local/sbin/dovecot-wrapper.sh<br />
sudo chmod a+x /usr/local/sbin/dovecot-wrapper.sh</p>
<p>Then, change the dovecot .plist above to run this script instead of dovecot by replacing &#8220;/usr/local/sbin/dovecot&#8221; with /usr/local/sbin/dovecot-wrapper.sh&#8221;, and removing the subsequent line containing &#8220;-F&#8221; (since this option is in the wrapper).</p>
<p>Finally, reload the launchd .plist:<br />
sudo launchctl unload /System/Library/LaunchDaemons/org.dovecot.plist<br />
sudo launchctl load /System/Library/LaunchDaemons/org.dovecot.plist</p>
<p>The wrapper runs dovecot as a front-process (-F), so the script will keep running as long as dovecot is running, which keeps launchd happy.  Any command that kills dovecot will also terminate the script, which will cause launchd to relaunch it via the script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11187</link>
		<dc:creator>Andrei</dc:creator>
		<pubDate>Sat, 16 Jul 2011 02:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11187</guid>
		<description>Well, that is the command I forgot, All&#039;s well that ends well. Thanks for the tip though. Maybe it will help some other poor soul who is having issues. :-)</description>
		<content:encoded><![CDATA[<p>Well, that is the command I forgot, All&#8217;s well that ends well. Thanks for the tip though. Maybe it will help some other poor soul who is having issues. <img src='http://diymacserver.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11172</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Fri, 15 Jul 2011 07:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11172</guid>
		<description>Andrei, normally you would do this using a command line editor like &quot;vi&quot; in combination with sudo. Logging in as root is never a good idea. A better solution would be to create the files as you did and then use the command &quot;chown root com.diymacserver.postfix.plist&quot;to change the ownership.</description>
		<content:encoded><![CDATA[<p>Andrei, normally you would do this using a command line editor like &#8220;vi&#8221; in combination with sudo. Logging in as root is never a good idea. A better solution would be to create the files as you did and then use the command &#8220;chown root com.diymacserver.postfix.plist&#8221;to change the ownership.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11166</link>
		<dc:creator>Andrei</dc:creator>
		<pubDate>Fri, 15 Jul 2011 00:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11166</guid>
		<description>I figured it out. You have to enable and login as root and then open and re-save the files with BBedit. It gives the right permissions and it seems to run everything ok.</description>
		<content:encoded><![CDATA[<p>I figured it out. You have to enable and login as root and then open and re-save the files with BBedit. It gives the right permissions and it seems to run everything ok.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11165</link>
		<dc:creator>Andrei</dc:creator>
		<pubDate>Thu, 14 Jul 2011 23:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11165</guid>
		<description>Ok, it looks like if you create a file in BBEdit, it will save it in LaunchDaemons, but it won&#039;t be under &quot;root&quot; ownership. I need to figure out how to turn that file into the &quot;root&quot; owned file. That is what is causing the stupid &quot;Dubious Ownership&quot; error... I think...</description>
		<content:encoded><![CDATA[<p>Ok, it looks like if you create a file in BBEdit, it will save it in LaunchDaemons, but it won&#8217;t be under &#8220;root&#8221; ownership. I need to figure out how to turn that file into the &#8220;root&#8221; owned file. That is what is causing the stupid &#8220;Dubious Ownership&#8221; error&#8230; I think&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11163</link>
		<dc:creator>Andrei</dc:creator>
		<pubDate>Thu, 14 Jul 2011 21:57:02 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11163</guid>
		<description>P.S. It also does the same thing with the postfix .plist file</description>
		<content:encoded><![CDATA[<p>P.S. It also does the same thing with the postfix .plist file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei</title>
		<link>http://diymacserver.com/installing-the-mailserver/the-mailserver-on-leopard/starting-postfix-and-dovecot-automatically-on-leopard/comment-page-1/#comment-11162</link>
		<dc:creator>Andrei</dc:creator>
		<pubDate>Thu, 14 Jul 2011 21:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://diymacserver.com/?page_id=707#comment-11162</guid>
		<description>Hi, when I try to load the .plist file, I get the following error message:

Dubious ownership on file (skipping): /System/Library/LaunchDaemons/com.diymacserver.dovecot.plist
nothing found to load

I followed the dovecot .plist file creation to the letter and it doesn&#039;t seem to want to do anything. Installation of dovecot 2.13 went over fine with no errors, but the SMTP server shows as offline. Thanks for any help.</description>
		<content:encoded><![CDATA[<p>Hi, when I try to load the .plist file, I get the following error message:</p>
<p>Dubious ownership on file (skipping): /System/Library/LaunchDaemons/com.diymacserver.dovecot.plist<br />
nothing found to load</p>
<p>I followed the dovecot .plist file creation to the letter and it doesn&#8217;t seem to want to do anything. Installation of dovecot 2.13 went over fine with no errors, but the SMTP server shows as offline. Thanks for any help.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

