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.

116 lines
3.9 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/clamd
  7. CLAMD_CONFIGFILE="/tmp/clamav/clamd.conf"
  8. validate_clamav_section() {
  9. uci_validate_section clamav clamav "${1}" \
  10. 'clamd_config_file:string' \
  11. 'LogFile:string' \
  12. 'LogFileMaxSize:string' \
  13. 'LogVerbose:string' \
  14. 'ExtendedDetectionInfo:string' \
  15. 'LogTime:string' \
  16. 'OfficialDatabaseOnly:string' \
  17. 'StreamMinPort:uinteger' \
  18. 'StreamMaxPort:uinteger' \
  19. 'MaxThreads:uinteger' \
  20. 'ReadTimeout:uinteger' \
  21. 'CommandReadTimeout:uinteger' \
  22. 'MaxDirectoryRecursion:uinteger' \
  23. 'FollowDirectorySymlinks:string' \
  24. 'FollowFileSymlinks:string' \
  25. 'SelfCheck:uinteger' \
  26. 'DetectPUA:string' \
  27. 'ScanPE:string' \
  28. 'DisableCertCheck:string' \
  29. 'ScanELF:string' \
  30. 'DetectBrokenExecutables:string' \
  31. 'ScanOLE2:string' \
  32. 'ScanPDF:string' \
  33. 'ScanSWF:string' \
  34. 'ScanMail:string' \
  35. 'ScanPartialMessages:string' \
  36. 'ScanArchive:string' \
  37. 'TemporaryDirectory:string' \
  38. 'ArchiveBlockEncrypted:string' \
  39. 'MaxFileSize:string' \
  40. 'LocalSocket:string' \
  41. 'User:string' \
  42. 'ExitOnOOM:string'
  43. }
  44. start_service() {
  45. local clamd_config_file LogFile LogTime StreamMinPort \
  46. StreamMaxPort MaxThreads ReadTimeout CommandReadTimeout MaxDirectoryRecursion \
  47. FollowFileSymlinks FollowDirectorySymlinks SelfCheck DetectPUA ScanPE DisableCertCheck \
  48. ScanELF DetectBrokenExecutables ScanOLE2 ScanPDF ScanSWF ScanMail ScanPartialMessages \
  49. ScanArchive TemporaryDirectory ArchiveBlockEncrypted MaxFileSize LocalSocket User
  50. validate_clamav_section clamav || {
  51. echo "validation failed"
  52. return 1
  53. }
  54. mkdir -p /usr/share/clamav
  55. mkdir -p /etc/clamav/
  56. mkdir -p /var/run/clamav/
  57. chmod a+rw /var/run/clamav
  58. mkdir -p $(dirname $CLAMD_CONFIGFILE)
  59. ln -sf $clamd_config_file $CLAMD_CONFIGFILE
  60. echo "LogFile " $LogFile > $CLAMD_CONFIGFILE
  61. echo "LogFileMaxSize " $LogFileMaxSize >> $CLAMD_CONFIGFILE
  62. echo "LogVerbose " $LogVerbose >> $CLAMD_CONFIGFILE
  63. echo "ExtendedDetectionInfo " $ExtendedDetectionInfo >> $CLAMD_CONFIGFILE
  64. echo "LogTime " $LogTime >> $CLAMD_CONFIGFILE
  65. echo "OfficialDatabaseOnly " $OfficialDatabaseOnly >> $CLAMD_CONFIGFILE
  66. echo "StreamMinPort " $StreamMinPort >> $CLAMD_CONFIGFILE
  67. echo "StreamMaxPort " $StreamMaxPort >> $CLAMD_CONFIGFILE
  68. echo "MaxThreads " $MaxThreads >> $CLAMD_CONFIGFILE
  69. echo "ReadTimeout " $ReadTimeout >> $CLAMD_CONFIGFILE
  70. echo "CommandReadTimeout " $CommandReadTimeout >> $CLAMD_CONFIGFILE
  71. echo "MaxDirectoryRecursion " $MaxDirectoryRecursion >> $CLAMD_CONFIGFILE
  72. echo "FollowDirectorySymlinks " $FollowDirectorySymlinks >> $CLAMD_CONFIGFILE
  73. echo "FollowFileSymlinks " $FollowFileSymlinks >> $CLAMD_CONFIGFILE
  74. echo "SelfCheck " $SelfCheck >> $CLAMD_CONFIGFILE
  75. echo "DetectPUA " $DetectPUA >> $CLAMD_CONFIGFILE
  76. echo "ScanPE " $ScanPE >> $CLAMD_CONFIGFILE
  77. echo "DisableCertCheck " $DisableCertCheck >> $CLAMD_CONFIGFILE
  78. echo "ScanELF " $ScanELF >> $CLAMD_CONFIGFILE
  79. echo "DetectBrokenExecutables " $DetectBrokenExecutables >> $CLAMD_CONFIGFILE
  80. echo "ScanOLE2 " $ScanOLE2 >> $CLAMD_CONFIGFILE
  81. echo "ScanPDF " $ScanPDF >> $CLAMD_CONFIGFILE
  82. echo "ScanSWF " $ScanSWF >> $CLAMD_CONFIGFILE
  83. echo "ScanMail " $ScanMail >> $CLAMD_CONFIGFILE
  84. echo "ScanPartialMessages " $ScanPartialMessages >> $CLAMD_CONFIGFILE
  85. echo "ScanArchive " $ScanArchive >> $CLAMD_CONFIGFILE
  86. echo "TemporaryDirectory " $TemporaryDirectory >> $CLAMD_CONFIGFILE
  87. echo "ArchiveBlockEncrypted " $ArchiveBlockEncrypted >> $CLAMD_CONFIGFILE
  88. echo "MaxFileSize " $MaxFileSize >> $CLAMD_CONFIGFILE
  89. echo "LocalSocket " $LocalSocket >> $CLAMD_CONFIGFILE
  90. echo "User " $User >> $CLAMD_CONFIGFILE
  91. echo "ExitOnOOM " $ExitOnOOM >> $CLAMD_CONFIGFILE
  92. procd_open_instance
  93. procd_set_param command $PROG -c $CLAMD_CONFIGFILE
  94. procd_set_param file $CLAMD_CONFIGFILE
  95. procd_close_instance
  96. }
  97. stop_service()
  98. {
  99. service_stop ${PROG}
  100. }
  101. service_triggers()
  102. {
  103. procd_add_reload_trigger "clamav"
  104. procd_add_validation validate_clamav_section
  105. }