Subject: pkg/24294: rc.d script for clamav
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <eric@cirr.com>
List: netbsd-bugs
Date: 02/01/2004 15:54:32
>Number:         24294
>Category:       pkg
>Synopsis:       rc.d script for clamav
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 01 21:55:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Eric Schnoebelen
>Release:        NetBSD 1.6ZH
>Organization:
Eric Schnoebelen		eric@cirr.com 		http://www.cirr.com
	Real programmers have trouble suppressing homicidal
		 tendencies when asked, "Are you sure?"
>Environment:
System: NetBSD egsner.cirr.com 1.6ZH NetBSD 1.6ZH (GENERIC.MP) #50: Mon Jan 26 08:09:37 CST 2004 eric@egsner.cirr.com:/work/eric/NetBSD-current/obj/i386/sys/arch/i386/compile/GENERIC.MP i386
Architecture: i386
Machine: i386
>Description:
	mail/clamav lacks a start up script for clamd
>How-To-Repeat:
	Install clamav, and let /etc/rc attempt to start it..

>Fix:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	files
#	files/clamd.sh
#
echo c - files
mkdir -p files > /dev/null 2>&1
echo x - files/clamd.sh
sed 's/^X//' >files/clamd.sh << 'END-of-files/clamd.sh'
X#!/bin/sh
X#
X# $NetBSD$
X#
X# clamd does anti-virus checking.
X#
X## only for NetBSD
X# PROVIDE: clamd
X# REQUIRE: LOGIN
X##	only because it might be used by mimedefang
X# BEFORE: mail
X# KEYWORD: shutdown
X##
X
XPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/pkg/bin
Xexport PATH
X
Xif [ -f /etc/rc.subr ]
Xthen
X	. /etc/rc.subr
Xfi
X
Xname="clamd"
Xrcvar=$name
Xrequired_files="/usr/pkg/etc/clamav.conf"
Xcommand="/usr/pkg/sbin/clamd"
Xpidfile=$(awk '/^#/ {next}; /PidFile/ {print $2}' ${required_files})
Xsocket=$(awk '/^#/ {next}; /LocalSocket/ {print $2}' ${required_files})
Xclamd_user=$(awk '/^#/ {next}; /User/ {print $2}' ${required_files})
Xsig_stop="TERM"
Xcommand_args=""
X
X# default values, may be overridden on NetBSD by setting them in /etc/rc.conf
Xclamd_flags=${clamd_flags-""}
Xclamd=${clamd:-NO}
X
Xclamd_start()
X{
X    if [ -n "${the_clamd_pid}" ]; then
X	    echo "${command} already running as pid ${the_clamd_pid}."
X	    return 1
X    fi
X    echo "Starting clamd"
X    rm -f ${pidfile} ${socket}
X    touch ${pidfile}
X    chown ${clamd_user} ${pidfile}
X    ${command} ${clamd_flags} ${command_args}
X}
X
Xstart_cmd="clamd_start"
X
Xload_rc_config $name
Xrun_rc_command "$1"
END-of-files/clamd.sh
exit
>Release-Note:
>Audit-Trail:
>Unformatted: