Date: Thu, 31 Dec 2009 14:15:10 -0500 From: Glen Barber <glen.j.barber@gmail.com> To: ports@freebsd.org Cc: "Philip M. Gollucci" <pgollucci@p6m7g8.com>, Doug Barton <dougb@freebsd.org> Subject: Re: cvs commit: ports/mail/p5-qpsmtpd/files qpsmtpd.in Message-ID: <4ad871310912311115g5c821d0bhd5d6c03f167deef1@mail.gmail.com> In-Reply-To: <4ad871310912141329r540d5cd9of33ec2963dbf999d@mail.gmail.com> References: <200912100507.nBA577Q3033700@repoman.freebsd.org> <4B2330FB.70309@FreeBSD.org> <4B243FBC.8080507@p6m7g8.com> <4B26A861.2080805@FreeBSD.org> <4ad871310912141329r540d5cd9of33ec2963dbf999d@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
On Mon, Dec 14, 2009 at 4:29 PM, Glen Barber <glen.j.barber@gmail.com> wrote:
> On Mon, Dec 14, 2009 at 4:04 PM, Doug Barton <dougb@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
[-- Attachment #2 --]
--- 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"
[-- Attachment #3 --]
--- 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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4ad871310912311115g5c821d0bhd5d6c03f167deef1>
