#!/bin/sh # # service-dovecot-run # John Simpson 2008-05-13 # # 2009-02-12 jms1 - added code to find and check pidfile. if it exists but # doesn't point to a running "dovecot" process, delete it before running # dovecot itself. (i actually did this back in 2008-06 but forgot to put it # on the web site, thanks to Ventyslav Vassilev for reminding me about it.) # ############################################################################### # # Copyright (C) 2008,2009 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### # note: DO NOT FORGET to add the "-F" option to the end of the command! CMD="/usr/local/sbin/dovecot -F" # may need to be removed PIDFILE="/usr/local/var/run/dovecot/master.pid" if [ -f $PIDFILE ] then PID=`cat $PIDFILE` if ps -p $PID -o comm= | grep -q dovecot then echo "ERROR: dovecot[$PID] is already running" sleep 5 exit 1 else rm -v $PIDFILE fi fi echo "command line: $CMD" exec env - PATH="/usr/bin:/bin" $CMD 2>&1 echo "exec failed" sleep 5