1 |
#! /bin/bash |
2 |
# |
3 |
# qpsmtpd-forkserver Start/Stop the qpsmtpd forking server |
4 |
# |
5 |
# chkconfig: 2345 90 60 |
6 |
# description: qpsmtpd is a flexible smtpd daemon written in Perl. \ |
7 |
# Apart from the core SMTP features, all functionality is \ |
8 |
# implemented in small "extension plugins" using the easy \ |
9 |
# to use object oriented plugin API. |
10 |
# processname: qpsmtpd-forkserver |
11 |
# config: /etc/qpsmtpd |
12 |
# pidfile: /var/run/qpsmtpd-forkserver.pid |
13 |
|
14 |
|
15 |
# Source function library. |
16 |
. /etc/init.d/functions |
17 |
. /etc/sysconfig/qpsmtpd-forkserver |
18 |
|
19 |
RETVAL=0 |
20 |
|
21 |
# See how we were called. |
22 |
|
23 |
prog="qpsmtpd-forkserver" |
24 |
|
25 |
start() { |
26 |
# cleanup environment a bit. |
27 |
unset PERL_UNICODE |
28 |
unset LANG |
29 |
unset LC_TIME |
30 |
unset LC_ALL |
31 |
unset BASH_ENV |
32 |
unset ENV |
33 |
unset CDPATH |
34 |
unset IFS |
35 |
|
36 |
echo -n $"Starting $prog: " |
37 |
trap "" 1 |
38 |
daemon $prog --detach $QPSMTPD_OPTIONS |
39 |
RETVAL=$? |
40 |
echo |
41 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog |
42 |
return $RETVAL |
43 |
} |
44 |
|
45 |
stop() { |
46 |
echo -n $"Stopping $prog: " |
47 |
killproc $prog |
48 |
RETVAL=$? |
49 |
echo |
50 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog |
51 |
return $RETVAL |
52 |
} |
53 |
|
54 |
# functions status() uses pidof, which doesn't work with (?) scripts |
55 |
qpstatus() { |
56 |
local base=${1##*/} |
57 |
local pid |
58 |
|
59 |
# Test syntax. |
60 |
if [ "$#" = 0 ] ; then |
61 |
echo $"Usage: status {program}" |
62 |
return 1 |
63 |
fi |
64 |
|
65 |
# Use "/var/run/*.pid" file for pid |
66 |
if [ -f /var/run/${base}.pid ] ; then |
67 |
read pid < /var/run/${base}.pid |
68 |
if [ -n "$pid" ]; then |
69 |
/bin/ps -p $pid >/dev/null |
70 |
if [ $? -eq 0 ]; then |
71 |
echo $"${base} (pid $pid) is running..." |
72 |
return 0 |
73 |
else |
74 |
echo $"${base} dead but pid file exists" |
75 |
return 1 |
76 |
fi |
77 |
fi |
78 |
fi |
79 |
# See if /var/lock/subsys/${base} exists |
80 |
if [ -f /var/lock/subsys/${base} ]; then |
81 |
echo $"${base} dead but subsys locked" |
82 |
return 2 |
83 |
fi |
84 |
echo $"${base} is stopped" |
85 |
return 3 |
86 |
} |
87 |
|
88 |
restart() { |
89 |
stop |
90 |
start |
91 |
} |
92 |
|
93 |
reload() { |
94 |
stop |
95 |
start |
96 |
} |
97 |
|
98 |
case "$1" in |
99 |
start) |
100 |
start |
101 |
;; |
102 |
stop) |
103 |
stop |
104 |
;; |
105 |
restart) |
106 |
restart |
107 |
;; |
108 |
reload) |
109 |
reload |
110 |
;; |
111 |
status) |
112 |
qpstatus qpsmtpd-forkserver |
113 |
;; |
114 |
condrestart) |
115 |
[ -f /var/lock/subsys/$prog ] && restart || : |
116 |
;; |
117 |
*) |
118 |
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}" |
119 |
exit 1 |
120 |
esac |
121 |
|
122 |
exit $? |