rc.uvscan 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
  2. ##
  3. ## rc.uvscan -- Run-Commands
  4. ##
  5. %config
  6. uvscan_enable="$openpkg_rc_def"
  7. uvscan_dat_url="ftp://ftp.nai.com/pub/antivirus/datfiles/4.x/"
  8. uvscan_dat_update="daily"
  9. %common
  10. rcService uvscan enable yes || exit 0
  11. uvscan_update () {
  12. # determine information
  13. uvscan_datadir="@l_prefix@/var/uvscan/data"
  14. uvscan_datfile=`@l_prefix@/bin/curl -s "$uvscan_dat_url" 2>/dev/null |\
  15. grep 'dat-[0-9][0-9]*\.tar' | sort | tail -1 |\
  16. sed -e 's;^.*\(dat-[0-9][0-9]*\.tar\).*$;\1;'`
  17. uvscan_tmpdir=`echo "${uvscan_datfile}" | sed -e 's;\.tar$;;'`
  18. # download and unpack latest DATs
  19. umask 077
  20. cd ${uvscan_datadir} || exit 1
  21. rm -f ${uvscan_datfile} >/dev/null 2>&1 || true
  22. @l_prefix@/bin/curl -s -o ${uvscan_datfile} \
  23. ${uvscan_dat_url}/${uvscan_datfile} || exit 1
  24. rm -rf ${uvscan_tmpdir} >/dev/null 2>&1 || true
  25. mkdir ${uvscan_tmpdir}
  26. ( cd ${uvscan_tmpdir} && @l_prefix@/bin/tar -xf ../${uvscan_datfile} ) || exit 1
  27. # update DAT repository by installing updated DAT files
  28. @l_prefix@/lib/openpkg/shtool install -m 644 -o @l_musr@ -g @l_mgrp@ \
  29. ${uvscan_tmpdir}/*.dat .
  30. uvscan_version=`echo "${uvscan_datfile}" | sed -e 's;^dat-;;' -e 's;\.tar$;;'`
  31. echo "${uvscan_version}" >VERSION
  32. # cleanup
  33. rm -f ${uvscan_datfile} >/dev/null 2>&1 || true
  34. rm -rf ${uvscan_tmpdir} >/dev/null 2>&1 || true
  35. }
  36. %hourly -u @l_musr@
  37. rcService uvscan enable yes || exit 0
  38. if [ ".$uvscan_dat_update" = .hourly ]; then
  39. uvscan_update || exit $?
  40. fi
  41. %daily -u @l_musr@
  42. rcService uvscan enable yes || exit 0
  43. if [ ".$uvscan_dat_update" = .daily ]; then
  44. uvscan_update || exit $?
  45. fi
  46. %weekly -u @l_musr@
  47. rcService uvscan enable yes || exit 0
  48. if [ ".$uvscan_dat_update" = .weekly ]; then
  49. uvscan_update || exit $?
  50. fi