83eb2c3700
literal name_enable wherever possible, and ${name}_enable when it's not, to prepare for the demise of set_rcvar(). In cases where I had to hand-edit unusual instances also modify formatting slightly to be more uniform (and in some cases, correct). This includes adding some $FreeBSD$ tags, and most importantly moving rcvar= to right after name= so it's clear that one is derived from the other.
105 lines
2.5 KiB
Bash
105 lines
2.5 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: clamav-milter
|
|
# REQUIRE: LOGIN clamd
|
|
# BEFORE: mail
|
|
# KEYWORD: shutdown
|
|
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable clamav-milter:
|
|
#
|
|
#clamav_milter_enable="YES"
|
|
#
|
|
# See clamav-milter(1) for flags
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name=clamav_milter
|
|
rcvar=clamav_milter_enable
|
|
|
|
conf_file=%%PREFIX%%/etc/clamav-milter.conf
|
|
command=%%PREFIX%%/sbin/clamav-milter
|
|
required_dirs=%%DBDIR%%
|
|
required_files=${conf_file}
|
|
|
|
start_precmd=start_precmd
|
|
start_postcmd=start_postcmd
|
|
|
|
start_precmd()
|
|
{
|
|
if [ -S "$clamav_milter_socket" ]; then
|
|
warn "Stale socket $clamav_milter_socket removed."
|
|
rm "$clamav_milter_socket"
|
|
fi
|
|
rc_flags="${flags:-$clamav_milter_flags}"
|
|
|
|
clamav_clamd_socket_prefix=${clamav_clamd_socket%:*}
|
|
# We can have inet or inet6, try to remove 6
|
|
clamav_clamd_socket_prefix=${clamav_clamd_socket_prefix%6}
|
|
|
|
if checkyesno clamav_clamd_enable && [ "x$clamav_clamd_socket" != "x" -a "${clamav_clamd_socket_prefix}" != "inet" ]; then
|
|
echo -n "Waiting for clamd socket.. "
|
|
i=${clamav_milter_socktimeout}
|
|
while [ $i -ne 0 ]
|
|
do
|
|
[ -S "$clamav_clamd_socket" ] && break
|
|
if [ `expr $i % 10` -eq 0 ]; then
|
|
echo -n "${i}.. "
|
|
fi
|
|
sleep 1
|
|
i=$(($i-1))
|
|
done
|
|
echo
|
|
if [ $i -eq 0 ]; then
|
|
echo "There is no clamd socket (${clamav_clamd_socket})!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
start_postcmd()
|
|
{
|
|
clamav_milter_socket_prefix=${clamav_milter_socket%:*}
|
|
# We can have inet or inet6, try to remove 6
|
|
clamav_milter_socket_prefix=${clamav_milter_socket_prefix%6}
|
|
|
|
if [ "x$clamav_milter_socket" != "x" -a "${clamav_milter_socket_prefix}" != "inet" ]; then
|
|
echo -n "Waiting for clamav-milter socket.. "
|
|
i=${clamav_milter_socktimeout}
|
|
while [ $i -ne 0 ]
|
|
do
|
|
[ -S "$clamav_milter_socket" ] && break
|
|
if [ `expr $i % 10` -eq 0 ]; then
|
|
echo -n "${i}.. "
|
|
fi
|
|
sleep 1
|
|
i=$(($i-1))
|
|
done
|
|
echo
|
|
if [ $i -eq 0 ]; then
|
|
echo "There is no clamav-milter socket (${clamav_milter_socket})!"
|
|
exit 1
|
|
fi
|
|
%%CHMOD%% ${clamav_milter_socket_mode} ${clamav_milter_socket}
|
|
%%CHOWN%% ${clamav_milter_socket_user}:${clamav_milter_socket_group} ${clamav_milter_socket}
|
|
fi
|
|
}
|
|
|
|
# read settings, set default values
|
|
load_rc_config $name
|
|
: ${clamav_milter_enable="NO"}
|
|
: ${clamav_milter_socket="%%CLAMAV_MILTER_SOCKET%%"}
|
|
: ${clamav_milter_flags="-c ${conf_file}"}
|
|
: ${clamav_milter_socktimeout="60"}
|
|
: ${clamav_milter_socket_mode="777"}
|
|
: ${clamav_milter_socket_user="%%CLAMAVUSER%%"}
|
|
: ${clamav_milter_socket_group="%%CLAMAVGROUP%%"}
|
|
|
|
: ${clamav_clamd_socket="%%CLAMAV_CLAMD_SOCKET%%"}
|
|
: ${clamav_clamd_enable="NO"}
|
|
|
|
run_rc_command "$1"
|