diff options
author | jlam <jlam@pkgsrc.org> | 2004-08-04 06:50:16 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2004-08-04 06:50:16 +0000 |
commit | a87b168c5fa0015fbf5ecfbfe529f15e4c1bcd26 (patch) | |
tree | 0dd1d3f8a199aa691f0e09596d2b39aaabcbd0cf /mail | |
parent | 4b4aecf04a267e8fad9b15ca1155ebe4508ac5a3 (diff) | |
download | pkgsrc-a87b168c5fa0015fbf5ecfbfe529f15e4c1bcd26.tar.gz |
Always specify the pidfile when starting clamsmtp.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/clamsmtp/files/clamsmtpd.sh | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/mail/clamsmtp/files/clamsmtpd.sh b/mail/clamsmtp/files/clamsmtpd.sh index 5561a423f09..1a7488e7ce3 100644 --- a/mail/clamsmtp/files/clamsmtpd.sh +++ b/mail/clamsmtp/files/clamsmtpd.sh @@ -1,11 +1,22 @@ #!@RCD_SCRIPTS_SHELL@ # -# $NetBSD: clamsmtpd.sh,v 1.2 2004/08/03 08:24:56 jlam Exp $ +# $NetBSD: clamsmtpd.sh,v 1.3 2004/08/04 06:50:16 jlam Exp $ # # PROVIDE: clamsmtpd # REQUIRE: LOGIN clamd # BEFORE: mail # KEYWORD: shutdown +# +# You will need to set some variables in /etc/rc.conf to start clamsmtpd: +# +# clamsmtpd=YES +# +# The following variables are optional: +# +# clamsmtpd_user="@CLAMAV_USER@" # user to run clamsmtpd as +# clamsmtpd_addr="localhost:10026" # address to forward mail to; +# # see clamsmtpd(8). +# if [ -f /etc/rc.subr ]; then . /etc/rc.subr @@ -14,26 +25,46 @@ fi name="clamsmtpd" rcvar=$name command="@PREFIX@/sbin/${name}" -clamsmtpd_user="@CLAMAV_USER@" +pidfile=/var/run/clamsmtpd.pid +: ${clamsmtpd_addr="localhost:10026"} + +start_precmd="clamsmtpd_prestart" +start_cmd="clamsmtpd_start" clamav_conffile="@PKG_SYSCONFDIR@/clamav.conf" if [ -f "${clamav_conffile}" ]; then socket=`@AWK@ 'BEGIN {r = "/tmp/clamd"}; /^#/ {next}; /^LocalSocket[ ]/ {r = $2}; END {print r}' ${clamav_conffile}` - clamsmtpd_user=`@AWK@ 'BEGIN {r = "@CLAMAV_USER@"}; + : ${clamsmtpd_user=`@AWK@ 'BEGIN {r = "@CLAMAV_USER@"}; /^#/ {next}; /^User[ ]/ {r = $2}; - END {print r}' ${clamav_conffile}` - : ${clamsmtpd_flags="-c ${socket} localhost:10026"} + END {print r}' ${clamav_conffile}`} + : ${clamsmtpd_flags="-c ${socket}"} else - : ${clamsmtpd_flags="localhost:10026"} + : ${clamsmtpd_user="@CLAMAV_USER@"} fi -if [ -f /etc/rc.subr -a -f /etc/rc.conf \ - -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then +clamsmtpd_prestart() +{ + @TOUCH@ ${pidfile} + @CHOWN@ ${clamsmtpd_user} ${pidfile} +} + +clamsmtpd_start() +{ + @ECHO@ "Starting ${name}." + doit="${command} ${clamsmtpd_flags} -p ${pidfile} ${clamsmtpd_addr}" + @SU@ -m ${clamsmtpd_user} -c "$doit" +} + +if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then load_rc_config $name run_rc_command "$1" else + if [ -f /etc/rc.conf ]; then + . /etc/rc.conf + fi @ECHO@ -n " ${name}" - ${command} ${clamsmtpd_flags} ${command_args} + eval ${start_precmd} + eval ${start_cmd} fi |