summaryrefslogtreecommitdiff
path: root/mail/mimedefang/files/patch-examples__init-script.in
blob: 54e34a2a176379c125b2e2bccdec15b0366c6512 (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
--- examples/init-script.in.orig	2010-06-30 01:50:32.000000000 +0400
+++ examples/init-script.in	2011-12-14 00:40:09.284988761 +0400
@@ -39,6 +39,12 @@
 # The socket used by mimedefang to communicate with sendmail
 # SOCKET=$SPOOLDIR/mimedefang.sock
 
+# Timeout while waiting for socket to appear
+# SOCKET_TIMEOUT=60
+
+# The value of socket file access mode
+# SOCKET_MODE=600
+
 # Run the multiplexor and filters as this user, not root.  RECOMMENDED
 MX_USER=@DEFANGUSER@
 
@@ -132,11 +138,11 @@
 
 # Limit slave processes' resident-set size to this many kilobytes.  Default
 # is unlimited.
-# MX_MAX_RSS=10000
+MX_MAX_RSS=100000
 
 # Limit total size of slave processes' memory space to this many kilobytes.
 # Default is unlimited.
-# MX_MAX_AS=30000
+MX_MAX_AS=300000
 
 # If you want to use the "notification" facility, set the appropriate port.
 # See the mimedefang-notify man page for details.
@@ -193,6 +199,7 @@
     procname=$PROGDIR/$prog-multiplexor
     start_cmd="start_it"
     stop_cmd="stop_it"
+    restart_cmd="restart_it"
     sig_reload="INT"
     reread_cmd="reread_it"
     # provide both "reload", the FreeBSD default, with a direct signal to
@@ -203,6 +210,8 @@
 # Make sure required vars are set
 SOCKET=${SOCKET:=$SPOOLDIR/$prog.sock}
 MX_SOCKET=${MX_SOCKET:=$SPOOLDIR/$prog-multiplexor.sock}
+SOCKET_TIMEOUT=${SOCKET_TIMEOUT:=60}
+SOCKET_MODE=${SOCKET_MODE:=600}
 
 start_it() {
     if test -r $PID ; then
@@ -286,6 +295,29 @@
 	kill `cat $MXPID`
 	return 1
     fi
+
+    SOCKET_PREFIX=${SOCKET%:*}
+    # We can have inet or inet6, try to remove 6
+    SOCKET_PREFIX=${SOCKET_PREFIX%6}
+
+    if [ "x$SOCKET" != "x" -a "${SOCKET_PREFIX}" != "inet" ] ; then
+        printf "Waiting for $prog socket."
+        i=${SOCKET_TIMEOUT}
+        while [ $i -ne 0 ]
+        do
+            [ -S "$SOCKET" ] && break
+            printf "."
+            sleep 1
+            i=$(($i-1))
+        done
+        echo ""
+        if [ $i -eq 0 ] ; then
+            echo "There is no $prog socket (${SOCKET})!"
+            return 1
+        fi
+        %%CHMOD%% ${SOCKET_MODE} ${SOCKET} > /dev/null 2>&1
+    fi
+
     return 0
 }
 
@@ -321,7 +353,7 @@
     rm -f $MX_SOCKET > /dev/null 2>&1
     rm -f $SOCKET > /dev/null 2>&1
 
-    if [ "$1" = "wait" ] ; then
+    if [ 1 ] ; then
 	printf "Waiting for daemons to exit."
 	WAITPID=""
 	test -f $PID && WAITPID=`cat $PID`
@@ -373,6 +405,12 @@
 	fi
 }
 
+restart_it() {
+    stop_it wait
+    start_it
+    RETVAL=$?
+}
+
 if type run_rc_command > /dev/null 2>&1
 then
     # NetBSD/FreeBSD compatible startup script