5 # Required-Start: $syslog $time $local_fs $remote_fs $named $network
6 # Required-Stop: $syslog $time $local_fs $remote_fs
7 # Default-Start: 2 3 4 5
9 # Short-Description: Start the OpenDMARC service
10 # Description: Enable DMAR verification and reporting provided by OpenDMARC
13 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
14 DAEMON
=/usr
/sbin
/opendmarc
20 SOCKET
=local:$RUNDIR/$NAME.sock
21 PIDFILE
=$RUNDIR/$NAME.pid
23 # How long to wait for the process to die on stop/restart
26 test -x $DAEMON ||
exit 0
28 # Include LSB provided init functions
29 .
/lib
/lsb
/init-functions
31 # Include opendkim defaults if available
32 if [ -f /etc
/default
/opendmarc
] ; then
33 .
/etc
/default
/opendmarc
36 if [ -f /etc
/opendmarc.conf
]; then
37 CONFIG_SOCKET
=`awk '$1 == "Socket" { print $2 }' /etc/opendmarc.conf`
40 # This can be set via Socket option in config file, so it's not required
41 if [ -n "$SOCKET" -a -z "$CONFIG_SOCKET" ]; then
42 DAEMON_OPTS
="-p $SOCKET $DAEMON_OPTS"
45 DAEMON_OPTS
="-c /etc/opendmarc.conf -u $USER -P $PIDFILE $DAEMON_OPTS"
48 # Create the run directory if it doesn't exist
49 if [ ! -d "$RUNDIR" ]; then
50 install -o "$USER" -g "$GROUP" -m 755 -d "$RUNDIR" ||
return 2
51 [ -x /sbin
/restorecon
] && /sbin
/restorecon
"$RUNDIR"
53 # Clean up stale sockets
54 if [ -f "$PIDFILE" ]; then
56 if ! ps
-C "$DAEMON" -s "$pid" >/dev
/null
; then
59 if [ -n "$SOCKET" ]; then
61 elif [ -n "$CONFIG_SOCKET" ]; then
62 TMPSOCKET
="$CONFIG_SOCKET"
64 if [ -n "$TMPSOCKET" ]; then
65 # UNIX sockets may be specified with or without the
66 # local: prefix; handle both
67 t
=`echo $SOCKET | cut -d: -f1`
68 s
=`echo $SOCKET | cut -d: -f2`
69 if [ -e "$s" -a -S "$s" ]; then
70 if [ "$t" = "$s" -o "$t" = "local" ]; then
77 start-stop-daemon
--start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test -- $DAEMON_OPTS ||
return 1
78 start-stop-daemon
--start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" -- $DAEMON_OPTS ||
return 2
82 start-stop-daemon
--stop --retry "$stoptimeout" --exec "$DAEMON"
83 [ "$?" = 2 ] && return 2
87 start-stop-daemon
--stop --signal USR1
--exec "$DAEMON"
91 local pidfile daemon name status
95 while getopts p
: opt
; do
97 p
) pidfile
="$OPTARG";;
100 shift $
(($OPTIND - 1))
102 if [ -n "$pidfile" ]; then
103 pidfile
="-p $pidfile"
109 pidofproc
$pidfile $daemon >/dev
/null || status
="$?"
110 if [ "$status" = 0 ]; then
111 log_success_msg
"$name is running"
114 log_failure_msg
"$name is not running"
121 echo -n "Starting $DESC: "
126 echo -n "Stopping $DESC: "
131 echo -n "Restarting $DESC: "
137 echo -n "Restarting $DESC: "
146 echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2