blob: ef6e1a6ff5de31fdfd592d154a31f00846ec7e80 (
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
|
#!/bin/bash
#
# opendkim Start and stop OpenDKIM.
# OpenDKIM startup script for Slackware 14.1 by Gerardo Zamudio
# Modified from the script by Steve Jenkins (SteveJenkins.com) - 10-29-2012
# Based on a script by Andrew Colin Kissa (TopDog) for dkim-milter - 05-28-2009
DKUSER="@DKUSER@"
DKGROUP="@DKGROUP@"
PROGRAM=/usr/sbin/opendkim
CONF_FILE=/etc/opendkim.conf
PID_FILE=/var/run/opendkim/opendkim.pid
KEYGEN=/usr/sbin/opendkim-genkey
DKIM_KEYDIR=/etc/opendkim/keys
DKIM_SELECTOR=default
AUTOCREATE_DKIM_KEYS=yes
do_dkim_keygen() {
if [ ! -s $DKIM_KEYDIR/$DKIM_SELECTOR.private ]; then
echo -n $"Generating default DKIM keys: "
if [ "x$(hostname -d)" = "x" ]; then
echo $"Cannot determine host's domain name, so skipping default key generation."
else
mkdir -p $DKIM_KEYDIR
$KEYGEN -b 2048 -D $DKIM_KEYDIR -s $DKIM_SELECTOR -d "$(hostname -d)"
chown root:$DK_USER $DKIM_KEYDIR
chown $DKUSER:$DKGROUP $DKIM_KEYDIR/$DKIM_SELECTOR.{private,txt}
chmod 600 $DKIM_KEYDIR/$DKIM_SELECTOR.private
chmod 644 $DKIM_KEYDIR/$DKIM_SELECTOR.txt
echo
echo Default DKIM keys for "$(hostname -d)" created in $DKIM_KEYDIR.
fi
fi
}
case "$1" in
start)
# Create keys if necessary
if [ "x${AUTOCREATE_DKIM_KEYS}" != xNO ]; then
do_dkim_keygen
fi
echo -n $"Starting OpenDKIM Milter... "
echo
if [ -f $PID_FILE ]; then
PID=$(cat $PID_FILE)
echo OpenDKIM already running as pid "$PID"
exit 2;
else
mkdir -p $(dirname $PID_FILE)
chown $DKUSER:$DKGROUP $(dirname $PID_FILE)
$PROGRAM -l -x $CONF_FILE -P $PID_FILE
fi
;;
stop)
echo -n $"Stopping OpenDKIM Milter... "
echo
if [ ! -f $PID_FILE ]; then
echo OpenDKIM is not running!
exit 2;
else
kill -TERM "$(cat $PID_FILE)" && rm -rf $PID_FILE
fi
;;
status)
if [ -f $PID_FILE ]; then
PID=$(cat $PID_FILE)
echo OpenDKIM already running as pid "$PID"
exit 2;
else
echo OpenDKIM is not running!
fi
;;
*)
echo $"Usage: $0 {start|stop|status|}"
exit 1
esac
exit $?
|