cvs commit: ports/mail/p5-qpsmtpd/files qpsmtpd.in

Glen Barber glen.j.barber at gmail.com
Thu Dec 31 19:15:20 UTC 2009


Hi,

On Mon, Dec 14, 2009 at 4:29 PM, Glen Barber <glen.j.barber at gmail.com> wrote:
> On Mon, Dec 14, 2009 at 4:04 PM, Doug Barton <dougb at freebsd.org> wrote:
>> Philip M. Gollucci wrote:
>>> I need to update it 0.83 anyway.
>>> I was going to rewrite the whole rc.d script from sratch at that time.
>>> In the meantime though this particular thing should help that person
>>> until I have time.
[...]
>
> I can have another look at this either tonight or tomorrow evening,
> unless someone updates it beforehand.  I will even update to 0.83 in
> the process.
>

I have attached two diffs of the rc script,  however I have run into a
few issues with both.

The first diff still uses 'stop_cmd(){kill `cat $pidfile`}' for the
following reasons:

  - adding ': qpsmtpd_pidfile="$pidfile"' would never create
/var/run/qpsmtpd.pid, thus the rc script would never find it to kill
the process.  To work around this, I added the pidfile creation to
start_cmd().

  - as a side effect of the above workaround, stopping the process
would kill the PID, however leave the pidfile.  As a second
workaround, I have kept the stop_cmd() function, and forcibly removed
the pidfile after the process was killed.

The second replaces the pidfile line with this:

  [ -z "$pidfile" ] && pidfile="/var/run/${name}.pid"

and adds a command_args line, however the pidfile is still not cleaned
after stopping the service, so stop_cmd() is used again.  Is there a
more correct way to clean up the pidfile that what I have attached?

Regards, and have a happy and safe new year.

-- 
Glen Barber
-------------- next part --------------
--- qpsmtpd.in.1.orig	2009-12-31 14:02:16.000000000 -0500
+++ qpsmtpd.in.1	2009-12-31 14:04:16.000000000 -0500
@@ -16,85 +16,30 @@
 
 name="qpsmtpd"
 rcvar=`set_rcvar`
-load_rc_config $name
+pidfile="/var/run/qpsmtpd.pid"
 
 command="%%PREFIX%%/bin/qpsmtpd-forkserver"
-pidfile="/var/run/qpsmtpd/qpsmtpd.pid"
 
-start_precmd="start_precmd"
 start_cmd="start_cmd"
 stop_cmd="stop_cmd"
 
-start_precmd()
-{
-    #exits if no user is specified
-    if [ -z $qpsmtpd_user ]; then
-	echo "qpsmtpd_user not set"
-	exit 1
-    fi
-
-    #exits if no group is specified
-    if [ -z $qpsmtpd_group ]; then
-	echo "qpsmtpd_group not set"
-	exit 1
-    fi
-
-    #sets it to the default if the port is not specified
-    if [ -z $qpsmtpd_port ]; then
-	qpsmtpd_port="2525"
-    fi
-    
-    #set it to the default max per ip
-    if [ -z $qpsmtpd_max_per_ip ]; then
-	qpsmtpd_max_per_ip="5"
-    fi
-    
-    #set it do the max number of connections total
-    if [ -z $qpsmtpd_max_connections ]; then
-	qpsmtpd_max_connections="15"
-    fi
-    
-    #set the default listen on to everything
-    if [ -z $qpsmtpd_listen_on ]; then
-	qpsmtpd_listen_on="0.0.0.0"
-    fi
-
-    if [ ! -d /var/run/qpsmtpd/ ] ; then
-	mkdir /var/run/qpsmtpd
-    fi
-    
-    chown $qpsmtpd_user:$qpsmtpd_group /var/run/qpsmtpd    
-}
-
-start_cmd()
-{
-	if [ -e $pidfile ]; then
-		echo "$name already running as PID `cat $pidfile`."
-		exit 1
-	else
-		eval $command \
-		-p $qpsmtpd_port \
-		-c $qpsmtpd_max_connections \
-		-u $qpsmtpd_user \
-		-m $qpsmtpd_max_per_ip \
-		-l $qpsmtpd_listen_on \
-		--pid-file $pidfile \
-		-d \
-		&& echo "$name started as PID `cat $pidfile`." \
-		|| echo "Failed to start $name"
-	fi
-}
-
-stop_cmd()
-{
-	if [ -e $pidfile ]; then
-		kill `cat $pidfile` \
-		&& echo "$name stopped." \
-		|| echo "Could not stop `cat $pidfile`."
-	else
-		echo "Cannot find $pidfile - $name not running?"
-		exit 1
-	fi
+load_rc_config $name
+: qpsmtpd_enable="NO"
+: qpsmtpd_user="smtpd"
+: qpsmtpd_group="smtpd"
+: qpsmtpd_port="2525"
+: qpsmtpd_max_per_ip="3"
+: qpsmtpd_max_connections="15"
+: qpsmtpd_listen_on="0.0.0.0"
+
+start_cmd() {
+	echo "Starting $name."
+	eval $command -d --pid-file $pidfile
+} 
+
+stop_cmd() {
+	echo "Stopping $name."
+	kill `cat $pidfile` && rm $pidfile
 }
 
 run_rc_command "$1"
-------------- next part --------------
--- qpsmtpd.in.2.orig	2009-12-31 14:02:18.000000000 -0500
+++ qpsmtpd.in.2	2009-12-31 14:05:17.000000000 -0500
@@ -16,85 +16,27 @@
 
 name="qpsmtpd"
 rcvar=`set_rcvar`
-load_rc_config $name
 
 command="%%PREFIX%%/bin/qpsmtpd-forkserver"
-pidfile="/var/run/qpsmtpd/qpsmtpd.pid"
 
-start_precmd="start_precmd"
-start_cmd="start_cmd"
 stop_cmd="stop_cmd"
 
-start_precmd()
-{
-    #exits if no user is specified
-    if [ -z $qpsmtpd_user ]; then
-	echo "qpsmtpd_user not set"
-	exit 1
-    fi
-
-    #exits if no group is specified
-    if [ -z $qpsmtpd_group ]; then
-	echo "qpsmtpd_group not set"
-	exit 1
-    fi
-
-    #sets it to the default if the port is not specified
-    if [ -z $qpsmtpd_port ]; then
-	qpsmtpd_port="2525"
-    fi
-    
-    #set it to the default max per ip
-    if [ -z $qpsmtpd_max_per_ip ]; then
-	qpsmtpd_max_per_ip="5"
-    fi
-    
-    #set it do the max number of connections total
-    if [ -z $qpsmtpd_max_connections ]; then
-	qpsmtpd_max_connections="15"
-    fi
-    
-    #set the default listen on to everything
-    if [ -z $qpsmtpd_listen_on ]; then
-	qpsmtpd_listen_on="0.0.0.0"
-    fi
-
-    if [ ! -d /var/run/qpsmtpd/ ] ; then
-	mkdir /var/run/qpsmtpd
-    fi
-    
-    chown $qpsmtpd_user:$qpsmtpd_group /var/run/qpsmtpd    
-}
-
-start_cmd()
-{
-	if [ -e $pidfile ]; then
-		echo "$name already running as PID `cat $pidfile`."
-		exit 1
-	else
-		eval $command \
-		-p $qpsmtpd_port \
-		-c $qpsmtpd_max_connections \
-		-u $qpsmtpd_user \
-		-m $qpsmtpd_max_per_ip \
-		-l $qpsmtpd_listen_on \
-		--pid-file $pidfile \
-		-d \
-		&& echo "$name started as PID `cat $pidfile`." \
-		|| echo "Failed to start $name"
-	fi
-}
-
-stop_cmd()
-{
-	if [ -e $pidfile ]; then
-		kill `cat $pidfile` \
-		&& echo "$name stopped." \
-		|| echo "Could not stop `cat $pidfile`."
-	else
-		echo "Cannot find $pidfile - $name not running?"
-		exit 1
-	fi
-}
+load_rc_config $name
+: qpsmtpd_enable="NO"
+: qpsmtpd_user="smtpd"
+: qpsmtpd_group="smtpd"
+: qpsmtpd_port="2525"
+: qpsmtpd_max_per_ip="3"
+: qpsmtpd_max_connections="15"
+: qpsmtpd_listen_on="0.0.0.0"
+
+[ -z "$pidfile" ] && pidfile="/var/run/${name}.pid"
+
+stop_cmd() {
+	echo "Stopping $name."
+	kill `cat $pidfile` && rm $pidfile
+} 
+
+command_args="-d --pid-file $pidfile"
 
 run_rc_command "$1"


More information about the freebsd-ports mailing list