aboutsummaryrefslogtreecommitdiff
path: root/mail/opendmarc/files/opendmarc.in
blob: 48211f56c23bed9b30ee67a52971cffc3bdae0f8 (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
#!/bin/sh
# $FreeBSD$

# PROVIDE: opendmarc
# REQUIRE: LOGIN
# BEFORE:  mail
# KEYWORD: opendmarc

# Define these opendmarc_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/opendmarc
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#

. /etc/rc.subr

name="opendmarc"
rcvar=opendmarc_enable

start_precmd="dmarc_prepcmd"
stop_postcmd="dmarc_postcmd"
command="%%PREFIX%%/sbin/opendmarc"
_piddir="/var/run/opendmarc"

load_rc_config $name

opendmarc_enable=${opendmarc_enable-"NO"}
opendmarc_runas=${opendmarc_runas-"mailnull:mailnull"}
opendmarc_pidfile=${opendmarc_pidfile-"${_piddir}/pid"}
#opendmarc_socketspec=${opendmarc_socketspec-"local:${_piddir}/socket"}
opendmarc_socketspec=${opendmarc_socketspec-"inet:8893@localhost"}
opendmarc_cfgfile=${opendmarc_cfgfile-"%%PREFIX%%/etc/mail/opendmarc.conf"}
opendmarc_flags=${opendmarc_flags-"-l -P $opendmarc_pidfile \
 -c $opendmarc_cfgfile -p $opendmarc_socketspec -u $opendmarc_runas"}

dmarc_prepcmd ()
{
    if [ -S ${opendmarc_socketspec##local:} ] ; then
	rm -f ${opendmarc_socketspec##local:}
    elif [ -S ${opendmarc_socketspec##unix:} ] ; then
	rm -f ${opendmarc_socketspec##unix:}
    fi
    if [ ! -d ${_piddir} ] ; then
	mkdir -p ${_piddir}
    fi
    chown ${opendmarc_runas} ${_piddir}
}

dmarc_postcmd()
{
    if [ -S ${opendmarc_socketspec##local:} ] ; then
	rm -f ${opendmarc_socketspec##local:}
    elif [ -S ${opendmarc_socketspec##unix:} ] ; then
	rm -f ${opendmarc_socketspec##unix:}
    fi
    # just if the directory is empty
    rmdir ${_piddir} > /dev/null 2>&1
}

run_rc_command "$1"