home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June (Extra) / CHIP 2006-06.3.iso / program / opensource / clamav-devel.exe / contrib / init / SuSE / clamd
Encoding:
Text File  |  2006-05-16  |  2.4 KB  |  102 lines

  1. #! /bin/sh
  2. # v1.2 05-2004, martin fuxa, yeti@email.cz
  3. #
  4. ### BEGIN INIT INFO
  5. # Provides:       clamd
  6. # Required-Start: 
  7. # Required-Stop:  
  8. # Default-Start:  2 3 5
  9. # Default-Stop:   0 1 2 6
  10. # Description:    Control clamav daemon.
  11. ### END INIT INFO
  12. #
  13. ### HISTORY
  14. # 2004-05-27 ADD - FreshClam code
  15.  
  16. # Variables
  17. PID="/var/run/clamd.pid"
  18. SBIN="/usr/local/sbin/clamd"
  19. CONF="/etc/clamav.conf"
  20. WHAT="Clam AntiVirus"
  21.  
  22. # START_FRESHCLAM value: 1=true, 0 false
  23. START_FRESHCLAM=1
  24. FRESHCLAM_SBIN="/usr/local/bin/freshclam"
  25. FRESHCLAM_CONF="/etc/freshclam.conf"
  26. FRESHCLAM_WHAT="FreshClam"
  27.  
  28. # Source SuSE config
  29. . /etc/rc.status
  30.  
  31. test -x $SBIN || exit 5
  32. test -e $CONF || exit 5
  33.  
  34. if [ $START_FRESHCLAM = 1 ]
  35. then
  36.     test -x $FRESHCLAM_SBIN || exit 5
  37.     test -e $FRESHCLAM_CONF || exit 5
  38. fi
  39.  
  40. # First reset status of this service
  41. rc_reset
  42.  
  43. # Process request
  44. case "$1" in
  45.     start)
  46.         if [ $START_FRESHCLAM = 1 ]
  47.         then
  48.             echo -n "Starting ${FRESHCLAM_WHAT} ${FRESHCLAM_CONF}"
  49.             startproc $FRESHCLAM_SBIN --daemon --config-file=${FRESHCLAM_CONF}
  50.             rc_status -v
  51.         fi
  52.         echo -n "Starting ${WHAT} ${CONF} "
  53.         ## Start daemon with startproc(8). If this fails
  54.         ## the echo return value is set appropriate.
  55.         startproc $SBIN $CONF
  56.         # Remember status and be verbose
  57.         rc_status -v
  58.         ## start freshclam
  59.         
  60.     ;;
  61.     stop)
  62.         echo -n "Shutting down ${WHAT}"
  63.         ## Stop daemon with killproc(8) and if this fails
  64.         ## set echo the echo return value.
  65.         killproc -TERM $SBIN
  66.         # Remember status and be verbose
  67.         rc_status -v
  68.         if [ $START_FRESHCLAM = 1 ]
  69.         then
  70.             echo -n "Shutting down ${FRESHCLAM_WHAT}"
  71.             killproc -TERM $FRESHCLAM_SBIN
  72.             rc_status -v
  73.         fi
  74.     ;;
  75.     restart)
  76.         ## Stop the service and regardless of whether it was
  77.         ## running or not, start it again.
  78.         $0 stop
  79.         $0 start
  80.         # Remember status and be quiet
  81.         rc_status
  82.     ;;
  83.     status)
  84.         echo -n "Checking for ${WHAT} "
  85.         checkproc $SBIN
  86.         rc_status -v
  87.         if [ $START_FRESHCLAM = 1 ]
  88.         then
  89.             echo -n "Checking for ${FRESHCLAM_WHAT} "
  90.             checkproc $FRESHCLAM_SBIN
  91.             rc_status -v
  92.         fi
  93.     ;;
  94.  
  95.     *)
  96.         echo "Usage: $0 {start|stop|status|restart}"
  97.         exit 1
  98.     ;;
  99. esac
  100. rc_exit
  101. ### END
  102.