summaryrefslogtreecommitdiff
path: root/mail/qmail-run/files/qmail.sh
blob: 711e1aff5f5acfc8a17139693758e50c7cbeb599 (plain)
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
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: qmail.sh,v 1.1.1.1 2004/08/02 03:59:22 schmonz Exp $
#
# Master script for administrators to control qmail services.
# Usage resembles the qmailctl script from "Life with qmail".
#

# KEYWORD: nostart

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

rcd_dir=`@DIRNAME@ $0`

# NOTE: run_rc_command sets $rc_arg
#
forward_commands()
{
	# Backward compat with NetBSD <1.6:
	[ -z "$rc_arg" ] && rc_arg=$_arg

	for file in $COMMAND_LIST; do
		$rcd_dir/$file $rc_arg
	done
}

reverse_commands()
{
	# Backward compat with NetBSD <1.6:
	[ -z "$rc_arg" ] && rc_arg=$_arg

	REVCOMMAND_LIST=
	for file in $COMMAND_LIST; do
		REVCOMMAND_LIST="$file $REVCOMMAND_LIST"
	done
	for file in $REVCOMMAND_LIST; do
		$rcd_dir/$file $rc_arg
	done
}

qmailrcd()
{
	for service in $@; do
		$rcd_dir/qmail${service} $rc_arg
	done
}

qmail_help()
{
	@CAT@ <<HELP
   stop -- stops mail service (smtp connections refused, nothing goes out)
  start -- starts mail service (smtp connection accepted, mail can go out)
  pause -- temporarily stops mail service (connections accepted, nothing leaves)
   cont -- continues paused mail service
   stat -- displays status of mail service
    cdb -- rebuild the tcpserver cdb file for smtp and/or pop3
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
 reload -- sends qmail-send HUP, rereading locals and virtualdomains
  queue -- shows status of queue
   alrm -- same as doqueue
  flush -- same as doqueue
    hup -- same as reload
HELP
}

COMMAND_LIST="qmailsend qmailsmtpd qmailpop3d"

name="qmail"
start_cmd="forward_commands"
stop_cmd="reverse_commands"
doqueue_cmd="qmailrcd send"; alrm_cmd=${doqueue_cmd}; flush_cmd=${doqueue_cmd}
reload_cmd="qmailrcd send"; hup_cmd=${reload_cmd}
status_cmd="forward_commands"; stat_cmd=${status_cmd}
pause_cmd="forward_commands"
cont_cmd="forward_commands"
cdb_cmd="qmailrcd smtpd pop3d"
queue_cmd="qmailrcd send"
help_cmd="qmail_help"
extra_commands="pause cont stat status cdb doqueue reload queue alrm flush hup help"

if [ -f /etc/rc.subr ]; then
	run_rc_command "$1"
else
	@ECHO@ -n " ${name}"
	_arg="$1"
	${start_cmd}
fi