mirror of
https://git.freebsd.org/ports.git
synced 2025-06-06 05:10:29 -04:00
- Rework the rc.d script
Submitted by: dougb & Glen Barber <glen.j.barber@gmail.com>
This commit is contained in:
parent
766ab75197
commit
ada9c889a7
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=247075
2 changed files with 39 additions and 82 deletions
|
@ -36,6 +36,7 @@ MAN3= Qpsmtpd::Command.3 \
|
||||||
|
|
||||||
USE_RC_SUBR= qpsmtpd
|
USE_RC_SUBR= qpsmtpd
|
||||||
|
|
||||||
|
SUB_LIST+= PERL=${PERL}
|
||||||
SUB_LIST+= PORTNAME=${PORTNAME}
|
SUB_LIST+= PORTNAME=${PORTNAME}
|
||||||
SUB_FILES+= pkg-message
|
SUB_FILES+= pkg-message
|
||||||
|
|
||||||
|
|
|
@ -1,100 +1,56 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
# PROVIDE: qpsmtpd
|
# PROVIDE: qpsmtpd
|
||||||
# REQUIRE: NETWORKING SERVERS
|
# REQUIRE: LOGIN
|
||||||
# BEFORE: securelevel
|
# KEYWORD: shutdown
|
||||||
|
#
|
||||||
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
||||||
|
# to enable this service:
|
||||||
|
#
|
||||||
|
# qpsmtpd_enable (bool): Set to NO by default
|
||||||
|
# Set it to YES to enable qpsmtpd
|
||||||
|
# qpsmtpd_user (string): Set to "nobody" by default
|
||||||
|
# The user to run qpsmtpd-forkserver as
|
||||||
|
# qpsmtpd_group (string): Set to "nogroup" by default
|
||||||
|
# The group the pid dir will be chowned to
|
||||||
|
# qpsmtpd_port (int): Set to 2525 by default
|
||||||
|
# The port it should listen on
|
||||||
|
# qpsmtpd_max_per_ip (int): Set to 3 by default
|
||||||
|
# Max connections per IP
|
||||||
|
# qpsmtpd_max_connections (int): Set to 15 by default
|
||||||
|
# Maximum total connections
|
||||||
|
# qpsmtpd_listen_on (address): Set to 0.0.0.0 by default
|
||||||
|
# IP address to listen on
|
||||||
|
|
||||||
#variables
|
. /etc/rc.subr
|
||||||
#qpsmtpd_user = the user to run qpsmtpd-forkserver under
|
|
||||||
#qpsmtpd_group = the group the pid dir will be chowned to
|
|
||||||
#qpsmtpd_port = the port it should listen on
|
|
||||||
#qpsmtpd_max_per_ip = max connections per IP
|
|
||||||
#qpsmtpd_max_connections = maximum total connections
|
|
||||||
#qpsmtpd_listen_on = IP to listen on
|
|
||||||
|
|
||||||
. "/etc/rc.subr"
|
|
||||||
|
|
||||||
name="qpsmtpd"
|
name="qpsmtpd"
|
||||||
rcvar=`set_rcvar`
|
rcvar=`set_rcvar`
|
||||||
load_rc_config $name
|
|
||||||
|
|
||||||
command="%%PREFIX%%/bin/qpsmtpd-forkserver"
|
command="%%PREFIX%%/bin/qpsmtpd-forkserver"
|
||||||
|
command_interpreter=%%PERL%%
|
||||||
pidfile="/var/run/qpsmtpd/qpsmtpd.pid"
|
pidfile="/var/run/qpsmtpd/qpsmtpd.pid"
|
||||||
|
|
||||||
start_precmd="start_precmd"
|
start_precmd=${name}_prestart
|
||||||
start_cmd="start_cmd"
|
|
||||||
stop_cmd="stop_cmd"
|
|
||||||
|
|
||||||
start_precmd()
|
qpsmtpd_prestart()
|
||||||
{
|
{
|
||||||
#exits if no user is specified
|
[ -d /var/run/qpsmtpd ] || mkdir /var/run/qpsmtpd
|
||||||
if [ -z $qpsmtpd_user ]; then
|
chown $qpsmtpd_user:$qpsmtpd_group /var/run/qpsmtpd
|
||||||
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()
|
load_rc_config $name
|
||||||
{
|
|
||||||
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()
|
: ${qpsmtpd_enable="NO"}
|
||||||
{
|
: ${qpsmtpd_user="nobody"}
|
||||||
if [ -e $pidfile ]; then
|
: ${qpsmtpd_group="nogroup"}
|
||||||
kill `cat $pidfile` \
|
: ${qpsmtpd_port="2525"}
|
||||||
&& echo "$name stopped." \
|
: ${qpsmtpd_max_per_ip="3"}
|
||||||
|| echo "Could not stop `cat $pidfile`."
|
: ${qpsmtpd_max_connections="15"}
|
||||||
else
|
: ${qpsmtpd_listen_on="0.0.0.0"}
|
||||||
echo "Cannot find $pidfile - $name not running?"
|
|
||||||
exit 1
|
command_args="-d -p $qpsmtpd_port -c $qpsmtpd_max_connections -u $qpsmtpd_user -m $qpsmtpd_max_per_ip -l $qpsmtpd_listen_on --pid-file $pidfile"
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
run_rc_command "$1"
|
run_rc_command "$1"
|
||||||
|
|
Loading…
Add table
Reference in a new issue