summaryrefslogtreecommitdiff
path: root/mail/MailScanner-devel/files/patch-bin:mta.sh
blob: 94acdaf0af750a8fd07c5cc3eb8278b2f2caf9e4 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--- ../MailScanner-4.22-5.old/bin/mta.sh	Thu Jan  1 01:00:00 1970
+++ bin/mta.sh	Mon Aug 11 12:36:06 2003
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+outgoing_queue_time=15m
+mta=exim
+
+case "$mta" in
+	exim)
+		program=/usr/local/sbin/exim
+
+		if [ -f /usr/local/etc/exim/configure.in ]; then
+			incoming_config=/usr/local/etc/exim/configure.in
+		else
+			incoming_config=/usr/local/etc/exim/configure
+		fi
+
+		outgoing_config=/usr/local/etc/exim/configure.out
+
+		inpidfile=/var/run/exim_in.pid
+		outpidfile=/var/run/exim_out.pid
+		subpidfile=
+
+		incoming_args="-C ${incoming_config} -oP ${inpidfile} -bd"
+		outgoing_args="-C ${outgoing_config} -oP ${outpidfile} -q${outgoing_queue_time}"
+		submitqueue_args=
+		;;
+
+	sendmail)
+		program=/usr/sbin/sendmail
+
+		incoming_queue=/var/spool/mqueue.in
+
+		submit_queue_time=${outgoing_queue_time}
+
+		inpidfile=/var/run/sendmail_in.pid
+		outpidfile=/var/run/sendmail_out.pid
+		subpidfile=/var/spool/clientmqueue/sm-client.pid
+
+		incoming_args="-L sm-mta-in -bd \
+				-OPrivacyOptions=noetrn \
+				-OQueueDirectory=${incoming_queue} \
+				-ODeliveryMode=queueonly \
+				-OPidFile=${inpidfile}"
+		outgoing_args="-L sm-mta-out -q${outgoing_queue_time} \
+				-OPidFile=${outpidfile}"
+		submitqueue_args="-L sm-msp-queue -Ac -q${submit_queue_time} \
+				-OPidFile=${subpidfile}"
+		;;
+
+	*)
+		echo "ERROR: I don't know the MTA '$mta'. Check your settings." >&2
+		exit 2
+		;;
+esac
+
+start_mta()
+{
+	echo -n " `basename ${program}`(incoming)"
+	${program} ${incoming_args}
+
+	echo -n " `basename ${program}`(outgoing)"
+	${program} ${outgoing_args}
+}
+
+start_mspq ()
+{
+	if [ "${submitqueue_args}" ]; then
+		echo -n " `basename ${program}`(submitqueue)"
+		${program} ${submitqueue_args}
+	fi
+}
+
+stop_mta()
+{
+	echo "Stopping `basename ${program}` (incoming)"
+	kill -TERM `head -1 ${inpidfile}` 2>/dev/null
+
+	echo "Stopping `basename ${program}` (outgoing)"
+	kill -TERM `head -1 ${outpidfile}` 2>/dev/null
+}
+
+stop_mspq ()
+{
+	if [ "${submitqueue_args}" ]; then
+		echo "Stopping `basename ${program}` (submitqueue)"
+		kill -TERM `head -1 ${subpidfile}` 2>/dev/null
+	fi
+}
+
+
+_action=${1:-start}
+
+case ${_action} in
+start)
+        start_mta
+	start_mspq
+        ;;
+
+stop)
+        stop_mta
+	stop_mspq
+        ;;
+
+restart)
+	stop_mta
+	stop_mspq
+	sleep 5
+	start_mta
+	start_mspq
+	;;
+
+*)
+	echo "Usage: `basename $0` {start|stop|restart}" >&2
+	exit 64
+	;;
+esac
+exit 0
+