You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.5 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=90
  4. STOP=10
  5. USE_PROCD=1
  6. PROG=/usr/sbin/clamav-milter
  7. CLAMAV_MILTER_CONFIGFILE="/tmp/clamav/clamav-milter.conf"
  8. validate_clamav_milter_section() {
  9. uci_load_validate clamav-milter clamav_milter "$1" "$2" \
  10. 'clamav_milter_config_file:string' \
  11. 'Foreground:string' \
  12. 'PidFile:string' \
  13. 'User:string' \
  14. 'MilterSocketGroup:string' \
  15. 'AllowSupplementaryGroups:string' \
  16. 'ReadTimeout:uinteger' \
  17. 'OnClean:string' \
  18. 'OnInfected:string' \
  19. 'OnFail:string' \
  20. 'AddHeader:string' \
  21. 'LogVerbose:string' \
  22. 'LogTime:string' \
  23. 'LogSyslog:string' \
  24. 'LogFacility:string' \
  25. 'LogInfected:string' \
  26. 'LogClean:string' \
  27. 'MaxFileSize:string' \
  28. 'SupportMultipleRecipients:string' \
  29. 'RejectMsg:string' \
  30. 'TemporaryDirectory:string' \
  31. 'MilterSocket:string' \
  32. 'MilterSocketMode:uinteger' \
  33. 'ClamdSocket:string' \
  34. 'FixStaleSocket:string'
  35. }
  36. start_clamav_milter_instance() {
  37. [ "$2" = 0 ] || {
  38. echo "validation failed"
  39. return 1
  40. }
  41. mkdir -p /etc/clamav/
  42. mkdir -p /var/run/clamav/
  43. chmod a+rw /var/run/clamav
  44. mkdir -p "$(dirname $CLAMAV_MILTER_CONFIGFILE)"
  45. ln -sf "$clamav_milter_config_file" "$CLAMAV_MILTER_CONFIGFILE"
  46. {
  47. echo "Foreground " "$Foreground"
  48. echo "PidFile " "$PidFile"
  49. echo "User " "$User"
  50. echo "MilterSocketGroup " "$MilterSocketGroup"
  51. echo "AllowSupplementaryGroups " "$AllowSupplementaryGroups"
  52. echo "ReadTimeout " "$ReadTimeout"
  53. echo "OnClean " "$OnClean"
  54. echo "OnInfected " "$OnInfected"
  55. echo "OnFail " "$OnFail"
  56. echo "AddHeader " "$AddHeader"
  57. echo "LogVerbose " "$LogVerbose"
  58. echo "LogTime " "$LogTime"
  59. echo "LogSyslog " "$LogSyslog"
  60. echo "LogFacility " "$LogFacility"
  61. echo "LogInfected " "$LogInfected"
  62. echo "LogClean " "$LogClean"
  63. echo "MaxFileSize " "$MaxFileSize"
  64. echo "SupportMultipleRecipients " "$SupportMultipleRecipients"
  65. echo "RejectMsg " "$RejectMsg"
  66. echo "TemporaryDirectory " "$TemporaryDirectory"
  67. echo "MilterSocket " "$MilterSocket"
  68. echo "MilterSocketMode " "$MilterSocketMode"
  69. echo "ClamdSocket " "$ClamdSocket"
  70. echo "FixStaleSocket " "$FixStaleSocket"
  71. } > "$CLAMAV_MILTER_CONFIGFILE"
  72. procd_open_instance
  73. procd_set_param command $PROG -c $CLAMAV_MILTER_CONFIGFILE
  74. procd_set_param file $CLAMAV_MILTER_CONFIGFILE
  75. procd_close_instance
  76. }
  77. start_service()
  78. {
  79. validate_clamav_milter_section clamav_milter start_clamav_milter_instance
  80. }
  81. stop_service()
  82. {
  83. service_stop $PROG
  84. }
  85. service_triggers()
  86. {
  87. procd_add_reload_trigger "clamav-milter"
  88. procd_add_validation validate_clamav_milter_section
  89. }