blob: 433a81edb01b289a97a0e4b5b0cf604080cd39ea (
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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#!/bin/sh
# Startup script for amavisd-new daemon for use on Slackware Linux x86|x86_64
# Copyright (c) 2008-2018, Nishant Limbachia, Hoffman Estates, IL, USA
# (nishant _AT_ mnspace _DOT_ net)
# Usage: /etc/rc.d/rc.amavisd-new start|stop|restart|reload|status
# For automatic startup at boot, call this script from rc.local
# Notes - 03/25/2013 #
# With v2.8.0, amavis-mc daemon was added to the mix and so this rc script
# has been overhauled from the previous version. If you have suggestions to
# improve, please feel free to share.
# Script starts three different daemons: amavis-mc, amavisd-signer & amavisd
# All the daemons have their own start and stop functions, however, amavisd
# also has restart and reload which are supported by the program.
# Assuming you want all 3 daemons, you can start all at once like this:
# /etc/rc.d/rc.amavisd-new start
MC_PID=/var/run/amavis/amavis-mc.pid
PID=/var/run/amavis/amavisd.pid
amavisd_signer_start() {
# start amavisd-signer
printf "Starting amavisd-signer daemon\n"
/usr/sbin/amavisd-signer
}
amavisd_signer_stop() {
# stop amavisd-signer first
printf "Stopping amavisd-signer daemon\n"
pkill amavisd-signer
}
amavis_mc_start() {
# start amavis-mc process
if [ -f $MC_PID ]; then
printf "amavis-mc daemon running with PID: $(cat $MC_PID)\n"
printf "Terminating previous amavis-mc process\n"
kill $(cat $MC_PID)
rm -f $MC_PID
printf "Starting amavis-mc daemon\n"
/usr/sbin/amavis-mc -P $MC_PID
else
printf "Starting amavis-mc daemon\n"
/usr/sbin/amavis-mc -P $MC_PID
fi
}
amavis_mc_stop() {
if [ -f $MC_PID ]; then
printf "Stopping amavis-mc daemon\n"
kill $(cat $MC_PID)
rm -f $MC_PID
else
printf "amavis-mc daemon is not running\n"
fi
}
amavisd_start() {
if [ -f $PID ]; then
printf "amavisd-new daemon running with PID: $(cat $PID)\n"
printf "Terminating previous amavisd-new process\n"
kill $(cat $PID)
rm -f $PID
printf "Starting amavisd-new daemon\n"
/usr/sbin/amavisd start
else
printf "Starting amavisd-new daemon\n"
/usr/sbin/amavisd start
fi
}
amavisd_stop() {
if [ -f $PID ]; then
printf "Stopping amavisd-new daemon\n"
/usr/sbin/amavisd stop
rm -f $PID
else
printf "amavisd-new daemon is not running\n"
fi
}
amavisd_reload() {
echo "Reloading amavisd-new daemon"
/usr/sbin/amavisd reload
}
amavisd_restart() {
printf "Restarting amavisd-new daemon\n"
/usr/sbin/amavisd restart
}
### This is where all the combined processes start
daemons_start() {
amavis_mc_start
sleep 2
amavisd_signer_start
sleep 2
amavisd_start
}
daemons_stop() {
amavisd_stop
amavisd_signer_stop
amavis_mc_stop
}
daemons_restart() {
amavis_mc_stop
sleep 2
amavis_mc_start
amavisd_signer_stop
sleep 2
amavisd_signer_start
sleep 2
amavisd_restart
}
daemons_status() {
printf "amavis-mc daemon running with PID: $(cat $MC_PID)\n"
printf "amavisd-new daemon running with PID: $(cat $PID)\n"
printf "amavisd-signer daemon running with PID: $(pgrep amavisd-signer)\n"
}
###
case "$1" in
'start')
daemons_start
;;
'stop')
daemons_stop
;;
'restart')
daemons_restart
;;
'reload')
amavisd_reload
;;
'status')
daemons_status
;;
*)
echo "USAGE: $0 start|stop|restart|reload|status"
exit 1
;;
esac
|