blob: 2c6866ff4a17f0b2ccefc4afca423520543eeb74 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#!/bin/sh
# PROVIDE: qpsmtpd
# REQUIRE: NETWORKING SERVERS
# BEFORE: securelevel
#variables
#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"
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
}
run_rc_command "$1"
|