NOTE: You should disable your init scripts in /etc/rc2.d /etc/rc3.d

First we must create a:

/var/svc/manifest/site/clamav.xml

file that contains the following:

<?xml version='1.0'?>
 <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--

        William Pool (Puddle) 05/06
        Service manifest for clamd & freshclam
        E-mail: rotaecho@yahoo.com
 -->

 <service_bundle type='manifest' name='clamav:default'>

 <service
         name='site/clamav'
         type='service'
         version='1'>
         <create_default_instance enabled='false' />
         <single_instance />

         <dependency name='fs'
                 grouping='require_all'
                 restart_on='none'
                 type='service'>
                 <service_fmri value='svc:/system/filesystem/local' />
         </dependency>

         <dependency name='net'
                 grouping='require_all'
                 restart_on='none'
                 type='service'>
                 <service_fmri value='svc:/network/loopback' />
         </dependency>

         <exec_method
                 type='method'
                 name='start'
                 exec='/lib/svc/method/svc-clamav start'
                 timeout_seconds='-1'>
         </exec_method>
         <exec_method
                 type='method'
                 name='stop'
                 exec='/lib/svc/method/svc-clamav stop'
                 timeout_seconds='-1'>
         </exec_method>

 </service>

 </service_bundle>

Now, we need to create a method file:

/lib/svc/method/svc-clamav

which contains:

#!/bin/sh
#set -x
# Start or stop Postfix
# 
# 05/06
# William Pool
# rotaecho@Yahoo.com
# 
. /lib/svc/share/smf_include.sh

PATH=/usr/bin:/sbin:/usr/sbin:/opt/sfw/bin:/opt/sfw/sbin

# Anti-virus startup daemon

    start() {
        /opt/sfw/bin/freshclam -d -c 50 -p /var/clamav/freshclam.pid &
        /opt/sfw/sbin/clamd &
}

    stop() {
        echo "Stopping FreshClam\n\c"
CMPID=`cat /var/clamav/clamd.pid`
FCPID=`cat /var/clamav/freshclam.pid`
/usr/bin/kill "$FCPID" > /dev/null 2>&1
/usr/bin/kill "$CMPID" > /dev/null 2>&1

}

case "$1" in
        start)
        start
;;
        stop)
        stop
;;
        restart)
        stop
        sleep 5
        start
;;
    status)
  
      /opt/swf/bin/freshclam status 
        ;;
    
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
    ;;
esac

exit 0

Change permissions of the files:

chmod 555 /lib/svc/method/svc-clamav
chown root:bin /lib/svc/method/svc-clamav
chmod 444 /var/svc/manifest/site/clamav.xml
chown root:sys /var/svc/manifest/site/clamav.xml

Install the ClamAV SMF

/usr/sbin/svccfg import /var/svc/manifest/site/clamav.xml
/usr/sbin/svcadm -v enable|disable|restart clamav

last edited 2006-05-27 20:38:22 by WilliamPool