Ticket #18219: qmailctl.in

File qmailctl.in, 3.4 KB (added by compconsultant@…, 16 years ago)

New version of file from previous version of port

Line 
1#!/bin/sh
2
3PATH=/opt/local/var/qmail/bin:/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
4export PATH
5
6QMAILDUID=`id -u qmaild`
7NOFILESGID=`id -g qmaild`
8
9case "$1" in
10  start)
11    echo "Starting qmail"
12    if svok /opt/local/var/service/qmail-send ; then
13      svc -u /opt/local/var/service/qmail-send /opt/local/var/service/qmail-send/log
14    else
15      echo "qmail-send supervise not running"
16    fi
17    if svok /opt/local/var/service/qmail-smtpd ; then
18      svc -u /opt/local/var/service/qmail-smtpd /opt/local/var/service/qmail-smtpd/log
19    else
20      echo "qmail-smtpd supervise not running"
21    fi
22    if [ -d /var/lock/subsys ]; then
23      touch /var/lock/subsys/qmail
24    fi
25    ;;
26  stop)
27    echo "Stopping qmail..."
28    echo "  qmail-smtpd"
29    svc -d /opt/local/var/service/qmail-smtpd /opt/local/var/service/qmail-smtpd/log
30    echo "  qmail-send"
31    svc -d /opt/local/var/service/qmail-send /opt/local/var/service/qmail-send/log
32    if [ -f /opt/local/var/lock/subsys/qmail ]; then
33      rm /var/lock/subsys/qmail
34    fi
35    ;;
36  stat)
37    svstat /opt/local/var/service/qmail-send
38    svstat /opt/local/var/service/qmail-send/log
39    svstat /opt/local/var/service/qmail-smtpd
40    svstat /opt/local/var/service/qmail-smtpd/log
41    qmail-qstat
42    ;;
43  doqueue|alrm|flush)
44    echo "Flushing timeout table and sending ALRM signal to qmail-send."
45    /opt/local/var/qmail/bin/qmail-tcpok
46    svc -a /opt/local/var/service/qmail-send
47    ;;
48  queue)
49    qmail-qstat
50    qmail-qread
51    ;;
52  reload|hup)
53    echo "Sending HUP signal to qmail-send."
54    svc -h /opt/local/var/service/qmail-send
55    ;;
56  pause)
57    echo "Pausing qmail-send"
58    svc -p /opt/local/var/service/qmail-send
59    echo "Pausing qmail-smtpd"
60    svc -p /opt/local/var/service/qmail-smtpd
61    ;;
62  cont)
63    echo "Continuing qmail-send"
64    svc -c /opt/local/var/service/qmail-send
65    echo "Continuing qmail-smtpd"
66    svc -c /opt/local/var/service/qmail-smtpd
67    ;;
68  restart)
69    echo "Restarting qmail:"
70    echo "* Stopping qmail-smtpd."
71    svc -d /opt/local/var/service/qmail-smtpd /opt/local/var/service/qmail-smtpd/log
72    echo "* Sending qmail-send SIGTERM and restarting."
73    svc -t /opt/local/var/service/qmail-send /opt/local/var/service/qmail-send/log
74    echo "* Restarting qmail-smtpd."
75    svc -u /opt/local/var/service/qmail-smtpd /opt/local/var/service/qmail-smtpd/log
76    ;;
77  cdb)
78    tcprules /opt/local/etc/tcp.smtp.cdb /opt/local/etc/tcp.smtp.tmp < /opt/local/etc/tcp.smtp
79    chmod 644 /opt/local/etc/tcp.smtp.cdb
80    echo "Reloaded /opt/local/etc/tcp.smtp."
81    ;;
82  help)
83    cat <<HELP
84   stop -- stops mail service (smtp connections refused, nothing goes out)
85  start -- starts mail service (smtp connection accepted, mail can go out)
86  pause -- temporarily stops mail service (connections accepted, nothing leaves)
87   cont -- continues paused mail service
88   stat -- displays status of mail service
89    cdb -- rebuild the tcpserver cdb file for smtp
90restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
91doqueue -- schedules queued messages for immediate delivery
92 reload -- sends qmail-send HUP, rereading locals and virtualdomains
93  queue -- shows status of queue
94   alrm -- same as doqueue
95  flush -- same as doqueue
96    hup -- same as reload
97HELP
98    ;;
99  *)
100    echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
101    exit 1
102    ;;
103esac
104
105exit 0