How to Install Amavis-milter for Debian Sendmail: An Example Startup script

Next Previous Contents

## 8. An Example Startup script

    #!/bin/sh
    # /etc/init.d/amavis-ramdisk
    # Script to run Amavis from a ram disk.

    # I keep my antiviral scanner and data files on a ramdisk for speed.
    AVDIR="/usr/local/share/av.original"
    RAMDISK="/usr/local/share/av.ramdisk"
    AMAVISBIN="/usr/local/sbin"
    AMAVISSOCK="/var/local/amavis"
    [ -d $AVDIR -a -d $RAMDISK ] || exit 0
    case "$1" in
    start)
       mke2fs /dev/ram0 > /dev/null 2>&1
       mount /dev/ram0 $RAMDISK
       cp $AVDIR/* $RAMDISK
       if [ -S $AMAVISSOCK/amavis-milter.sock ]; then
          rm -rf $AMAVISSOCK/amavis-milter.sock
       fi
       if [ -S $AMAVISSOCK/amavisd.sock ]; then
          rm -rf $AMAVISSOCK/amavisd.sock
       fi
       nohup $AMAVISBIN/amavis-milter -p $AMAVISSOCK/amavis-milter.sock &
       $AMAVISBIN/amavisd
    ;;
    stop)
       kill -9 `ps x | grep amavisd | grep -v grep | awk '{print $1}'`2> /dev/null
       kill -9 `ps x | grep amavis-milter | grep -v grep | awk '{print $1}'` 2> /dev/null
       # I need to sleep for some reason :(
       sleep 2umount /dev/ram0
    ;;
    *)
       echo "Usage: /etc/init.d/amavis-ramdisk {start|stop}"
       exit 1
    ;;
    esac
    exit 0

Don't forget to update your antivirus data files regularly.

> Send all comments and corrections to <jps@maxlingua.com>. Support free software!

Next Previous Contents