From 368fd8a0517f98176bfd0d181b7809e3888580fe Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Sun, 15 Jan 2012 20:35:29 +0000 Subject: [PATCH] Modernise rc scripts Submitted by: dougb (based on patch) --- mail/mailscanner/files/mailscanner.in | 32 +++++++++------------------ mail/mailscanner/files/mta.in | 8 +++---- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/mail/mailscanner/files/mailscanner.in b/mail/mailscanner/files/mailscanner.in index f4832a0ab7c7..5b930a11e217 100644 --- a/mail/mailscanner/files/mailscanner.in +++ b/mail/mailscanner/files/mailscanner.in @@ -7,10 +7,13 @@ # # Add the following lines to /etc/rc.conf to enable mailscanner: # mailscanner_enable (bool): Set to "NO" by default. -# Set it to "YES" to enable mailscanner +# Set it to "YES" to enable MailScanner # mailscanner_configfile (path): Set to "%%PREFIX%%/etc/MailScanner/MailScanner.conf" by default. # mailscanner_pidfile (path): Set to "/var/run/MailScanner.pid" by default. -# mailscanner_user (str): Set to "root" by default. If you changed the "Run As User" variable in MailScanner.conf and wish to disable taint mode, you MUST also set the same value here. +# mailscanner_user (str): Set to "root" by default. If you changed the +# "Run As User" variable in MailScanner.conf and +# wish to disable taint mode, you MUST also set +# the same value here. # . /etc/rc.subr @@ -21,31 +24,16 @@ rcvar=mailscanner_enable load_rc_config $name : ${mailscanner_enable="NO"} -: ${mailscanner_configfile="%%PREFIX%%/etc/MailScanner/MailScanner.conf"} -: ${mailscanner_pidfile="/var/run/MailScanner.pid"} + +required_files=${mailscanner_configfile:-"%%PREFIX%%/etc/MailScanner/MailScanner.conf"} +pidfile=${mailscanner_pidfile:-"/var/run/MailScanner.pid"} command="%%PREFIX%%/sbin/mailscanner" -pidfile=${mailscanner_pidfile} -command_args="${mailscanner_configfile}" +command_args="${required_files}" procname="MailScanner" extra_commands=reload required_files="${mailscanner_configfile}" - -pid_touch () -{ - touch $mailscanner_pidfile - chown $mailscanner_user $mailscanner_pidfile -} - -mailscanner_start() { - su -m ${mailscanner_user} -c "exec ${command} ${command_args}" -} - -if [ -n "${mailscanner_user}" ]; then - start_cmd="mailscanner_start" - start_precmd="pid_touch" -fi +start_precmd="install -o ${mailscanner_user:-root} /dev/null $pidfile" run_rc_command "$1" - diff --git a/mail/mailscanner/files/mta.in b/mail/mailscanner/files/mta.in index d1de08b42189..3e49935f72e8 100644 --- a/mail/mailscanner/files/mta.in +++ b/mail/mailscanner/files/mta.in @@ -16,9 +16,9 @@ # mta_flags (str): Set to "" by default. # Extra flags passed to start command. # mta_program (str): Path to program, defaults depending on $mta_type -# either to "/usr/sbin/sendmail" or "/usr/local/sbin/exim" +# either to "/usr/sbin/sendmail" or "%%LOCALBASE%%/sbin/exim" # mta_configfile (str): Config file, defaults depending on $mta_type either -# to "/etc/mail/sendmail.cf" or "/usr/local/etc/exim/configure" +# to "/etc/mail/sendmail.cf" or "%%LOCALBASE%%/etc/exim/configure" # mta_pidfile (str): PID file, defaults depending on $mta_type either # to "/var/run/sendmail.pid" or "/var/run/exim.pid" # @@ -79,8 +79,8 @@ case "${mta_type}" in ;; exim) - _mta_program="/usr/local/sbin/exim" - _mta_configfile="/usr/local/etc/exim/configure" + _mta_program="%%LOCALBASE%%/sbin/exim" + _mta_configfile="%%LOCALBASE%%/etc/exim/configure" _mta_pidfile="/var/run/exim.pid" ;; esac