Use REQUIRE in lieu of BEFORE where possible

Include KEYWORD: shutdown where necessary

Style fixes; indent functions, condense single-line functions, correct
order of load_rc_config

Index: amavis-milter.in
===================================================================
--- amavis-milter.in	(revision 305869)
+++ amavis-milter.in	(working copy)
@@ -2,16 +2,14 @@
 #
 # $FreeBSD$
 #
-
 # PROVIDE: amavis_milter
 # REQUIRE: amavisd
 # BEFORE: mail
 # KEYWORD: shutdown
-
 #
 # Add the following lines to /etc/rc.conf to enable amavis-milter:
 #
-#amavis_milter_enable="YES"
+# amavis_milter_enable="YES"
 #
 
 . /etc/rc.subr
@@ -19,14 +17,13 @@
 name=amavis_milter
 rcvar=amavis_milter_enable
 
+load_rc_config $name
+
+: ${amavis_milter_enable:=NO}
+: ${amavis_milter_flags=-D -p %%AMAVISDIR%%/amavis-milter.sock}
+: ${amavis_milter_user=%%AMAVISUSER%%}
+
 command=%%PREFIX%%/sbin/amavis-milter
 required_files=%%PREFIX%%/etc/amavisd.conf
 
-# set defaults
-
-amavis_milter_enable=${amavis_milter_enable:-"NO"}
-amavis_milter_flags=${amavis_milter_flags:-"-D -p %%AMAVISDIR%%/amavis-milter.sock"}
-amavis_milter_user=${amavis_milter_user:-"%%AMAVISUSER%%"}
-
-load_rc_config $name
-run_rc_command "$1"
+run_rc_command $1
Index: amavisd-snmp.in
===================================================================
--- amavisd-snmp.in	(revision 305869)
+++ amavisd-snmp.in	(working copy)
@@ -2,11 +2,9 @@
 #
 # $FreeBSD$
 #
-
 # PROVIDE: amavisd_snmp
 # REQUIRE: snmpd
 # KEYWORD: shutdown
-
 #
 # Add the following lines to /etc/rc.conf to enable amavisd-snmp-subagent:
 #
@@ -18,19 +16,19 @@
 name=amavisd_snmp
 rcvar=amavisd_snmp_enable
 
-command="%%PREFIX%%/sbin/amavisd-snmp-subagent"
-command_interpreter="%%PERL%%"
-pidfile="%%AMAVISDIR%%/amavisd-snmp.pid"
+load_rc_config $name
 
 # defaults
-amavisd_snmp_enable=${amavisd_snmp_enable:-"NO"}
-# amavis database directory
-amavisd_snmp_dbdir=${amavisd_snmp_dbdir:-"%%AMAVISDIR%%/db"}
+: ${amavisd_snmp_enable:=NO}
+: ${amavisd_snmp_dbdir=%%AMAVISDIR%%/db}
 # log_level 0..5, default 0
-amavisd_snmp_loglevel=${amavisd_snmp_loglevel:-"0"}
+: ${amavisd_snmp_loglevel=0}
 
-load_rc_config $name
+command=%%PREFIX%%/sbin/amavisd-snmp-subagent
+command_interpreter=%%PERL%%
+pidfile=${amavisd_pidfile:-%%AMAVISDIR%%/amavisd-snmp.pid}
 
 required_dirs=${amavisd_snmp_dbdir}
 amavisd_snmp_flags="-D ${amavisd_snmp_dbdir} -d ${amavisd_snmp_loglevel} -P ${pidfile}"
-run_rc_command "$1"
+
+run_rc_command $1
Index: amavisd.in
===================================================================
--- amavisd.in	(revision 305869)
+++ amavisd.in	(working copy)
@@ -2,16 +2,14 @@
 #
 # $FreeBSD$
 #
-
 # PROVIDE: amavisd
-# REQUIRE: LOGIN mysql postgresql
+# REQUIRE: LOGIN mysql postgresql amavis_p0fanalyzer
 # BEFORE: mail
 # KEYWORD: shutdown
-
 #
 # Add the following lines to /etc/rc.conf to enable amavisd:
 #
-#amavisd_enable="YES"
+# amavisd_enable="YES"
 #
 
 . /etc/rc.subr
@@ -19,47 +17,36 @@
 name=amavisd
 rcvar=amavisd_enable
 
+load_rc_config $name
+
+: ${amavisd_enable:=NO}
+pidfile=${amavisd_pidfile-"%%AMAVISDIR%%/amavisd.pid"}
+
 command=%%PREFIX%%/sbin/amavisd
 command_args='> /dev/null 2>&1'
 required_files=%%PREFIX%%/etc/amavisd.conf
-extra_commands="reload"
+extra_commands=reload
 
 start_precmd=start_precmd
+stop_postcmd="rm -f $pidfile"
+reload_cmd="$command reload"
 
+
 # possible values include: amavisd_ram="512m"
 # adds ram disk for amavisd defanging/decoding, speeds up large systems 10%
 start_precmd()
 {
-rm -rf %%AMAVISDIR%%/tmp/* %%AMAVISDIR%%/tmp/.* 2>/dev/null || true
-if [ ${amavisd_ram} ];then
-  echo "========================================================"
-  echo "WARNING: using ramdisk is reported to be unstable and"
-  echo "thus it is highly recommended to be turned off."
-  echo "========================================================"
-  df %%AMAVISDIR%%/tmp | grep -E '^(/dev/md|tmpfs)' > /dev/null
-  if [ $? -eq 1 ]; then
-    mdmfs -s ${amavisd_ram} -p 750 -w %%AMAVISUSER%%:%%AMAVISGROUP%% md %%AMAVISDIR%%/tmp || true
-  fi
-fi
+	rm -rf %%AMAVISDIR%%/tmp/* %%AMAVISDIR%%/tmp/.* 2>/dev/null || true
+	if [ ${amavisd_ram} ];then
+	  echo "========================================================"
+	  echo "WARNING: using ramdisk is reported to be unstable and"
+	  echo "thus it is highly recommended to be turned off."
+	  echo "========================================================"
+	  df %%AMAVISDIR%%/tmp | grep -E '^(/dev/md|tmpfs)' > /dev/null
+	  if [ $? -eq 1 ]; then
+	    mdmfs -s ${amavisd_ram} -p 750 -w %%AMAVISUSER%%:%%AMAVISGROUP%% md %%AMAVISDIR%%/tmp || true
+	  fi
+	fi
 }
-stop_postcmd=stop_postcmd
 
-stop_postcmd()
-{
-  rm -f $pidfile
-}
-
-reload_cmd=${name}_reload
-
-amavisd_reload()
-{
-  ${command} reload
-}
-
-# set defaults
-
-amavisd_enable=${amavisd_enable:-"NO"}
-amavisd_pidfile=${amavisd_pidfile:-"%%AMAVISDIR%%/amavisd.pid"}
-
-load_rc_config $name
-run_rc_command "$1"
+run_rc_command $1
Index: amavis-p0fanalyzer.in
===================================================================
--- amavis-p0fanalyzer.in	(revision 305869)
+++ amavis-p0fanalyzer.in	(working copy)
@@ -1,25 +1,28 @@
 #!/bin/sh
 # $FreeBSD$
-
+#
 # PROVIDE: amavis_p0fanalyzer
 # REQUIRE: DAEMON
-# BEFORE: amavisd
+# KEYWORD: shutdown
 
-amavis_p0fanalyzer_enable="${amavis_p0fanalyzer_enable-NO}"
-amavis_p0fanalyzer_p0f_filter="${amavis_p0fanalyzer_p0f_filter-"tcp dst port 25"}"
-amavis_p0fanalyzer_pidfile1="${amavis_p0fanalyzer_pidfile1-/var/run/p0fanalyzer1.pid}"
-amavis_p0fanalyzer_pidfile2="${amavis_p0fanalyzer_pidfile2-/var/run/p0fanalyzer2.pid}"
-amavis_p0fanalyzer_flags="${amavis_p0fanalyzer_flags-2345}"
-
 . /etc/rc.subr
 
-name="amavis_p0fanalyzer"
+name=amavis_p0fanalyzer
 rcvar=amavis_p0fanalyzer_enable
 
+load_rc_config $name
+
+: ${amavis_p0fanalyzer_enable:=no}
+: ${amavis_p0fanalyzer_p0f_filter:=tcp dst port 25}
+: ${amavis_p0fanalyzer_pidfile1=/var/run/p0fanalyzer1.pid}
+: ${amavis_p0fanalyzer_pidfile2=/var/run/p0fanalyzer2.pid}
+: ${amavis_p0fanalyzer_flags=2345}
+
 start_cmd=p0fanalyzer_start
 stop_cmd=p0fanalyzer_stop
 
-p0fanalyzer_start() {
+p0fanalyzer_start()
+{
 	echo "Starting p0f-analyzer." && \
 	  %%DAEMON%% ${amavis_p0fanalyzer_pidfile1} \
 	  %%PREFIX%%/bin/p0f "${amavis_p0fanalyzer_p0f_filter}" 2>&1 | \
@@ -27,10 +30,10 @@
 	  %%PREFIX%%/sbin/p0f-analyzer.pl ${amavis_p0fanalyzer_flags}
 }
 
-p0fanalyzer_stop() {
+p0fanalyzer_stop()
+{
 	/bin/kill `cat ${amavis_p0fanalyzer_pidfile2}` && rm ${amavis_p0fanalyzer_pidfile2}
 	/bin/kill `cat ${amavis_p0fanalyzer_pidfile1}` && rm ${amavis_p0fanalyzer_pidfile1}
 }
 
-load_rc_config $name
-run_rc_command "$1"
+run_rc_command $1
