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.

192 lines
7.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/e2guardian
  7. CONFIGFILE="/tmp/e2guardian/e2guardian.conf"
  8. validate_e2guardian_section() {
  9. uci_validate_section e2guardian e2guardian "${1}" \
  10. 'config_file:string' \
  11. 'accessdeniedaddress:string' \
  12. 'bannediplist:string' \
  13. 'contentscanexceptions:string' \
  14. 'contentscannertimeout:uinteger' \
  15. 'createlistcachefiles:string' \
  16. 'custombannedflashfile:string' \
  17. 'custombannedimagefile:string' \
  18. 'deletedownloadedtempfiles:string' \
  19. 'downloadmanager:string' \
  20. 'exceptioniplist:string' \
  21. 'filecachedir:string' \
  22. 'filtergroups:uinteger' \
  23. 'filtergroupslist:string' \
  24. 'filterip:ipaddr' \
  25. 'filterports:port:8080' \
  26. 'forcequicksearch:string' \
  27. 'forwardedfor:string' \
  28. 'hexdecodecontent:string' \
  29. 'initialtrickledelay:uinteger' \
  30. 'ipcfilename:string' \
  31. 'ipipcfilename:string' \
  32. 'languagedir:string' \
  33. 'language:string' \
  34. 'logadblocks:string' \
  35. 'logchildprocesshandling:string' \
  36. 'logclienthostnames:string' \
  37. 'logconnectionhandlingerrors:string' \
  38. 'logexceptionhits:range(0,2)' \
  39. 'logfileformat:range(1,6)' \
  40. 'loglevel:range(0,3)' \
  41. 'loglocation:string' \
  42. 'loguseragent:string' \
  43. 'maxagechildren:uinteger' \
  44. 'maxchildren:uinteger' \
  45. 'maxcontentfilecachescansize:uinteger' \
  46. 'maxcontentfiltersize:uinteger' \
  47. 'maxcontentramcachescansize:uinteger' \
  48. 'maxips:uinteger' \
  49. 'maxsparechildren:uinteger' \
  50. 'maxuploadsize:integer' \
  51. 'minchildren:uinteger' \
  52. 'minsparechildren:uinteger' \
  53. 'nodaemon:string' \
  54. 'nologger:string' \
  55. 'pcontimeout:range(5,300)' \
  56. 'perroomdirectory:string' \
  57. 'phrasefiltermode:range(0,3)' \
  58. 'prefercachedlists:string' \
  59. 'preforkchildren:uinteger' \
  60. 'preservecase:range(0,2)' \
  61. 'proxyexchange:range(20,300)' \
  62. 'proxyip:ipaddr' \
  63. 'proxyport:port:3128' \
  64. 'proxytimeout:range(5,100)' \
  65. 'recheckreplacedurls:string' \
  66. 'reverseaddresslookups:string' \
  67. 'reverseclientiplookups:string' \
  68. 'scancleancache:string' \
  69. 'showweightedfound:string' \
  70. 'softrestart:string' \
  71. 'trickledelay:uinteger' \
  72. 'urlcacheage:uinteger' \
  73. 'urlcachenumber:uinteger' \
  74. 'urlipcfilename:string' \
  75. 'usecustombannedflash:string' \
  76. 'usecustombannedimage:string' \
  77. 'usexforwardedfor:string' \
  78. 'weightedphrasemode:range(0,2)'
  79. }
  80. start_service() {
  81. local config_file accessdeniedaddress bannediplist contentscanexceptions contentscannertimeout \
  82. createlistcachefiles custombannedflashfile custombannedimagefile deletedownloadedtempfiles \
  83. downloadmanager exceptioniplist filecachedir loglocation \
  84. filtergroups filtergroupslist filterip filterports forcequicksearch forwardedfor hexdecodecontent \
  85. initialtrickledelay ipcfilename ipipcfilename language languagedir logadblocks logchildprocesshandling \
  86. logclienthostnames logconnectionhandlingerrors logexceptionhits logfileformat loglevel loguseragent \
  87. maxagechildren maxchildren maxcontentfilecachescansize maxcontentfiltersize maxcontentramcachescansize \
  88. maxips maxsparechildren maxuploadsize minchildren minsparechildren nodaemon nologger \
  89. pcontimeout perroomdirectory phrasefiltermode prefercachedlists preforkchildren preservecase proxyexchange \
  90. proxyip proxyport proxytimeout recheckreplacedurls reverseaddresslookups reverseclientiplookups scancleancache \
  91. showweightedfound softrestart trickledelay urlcacheage urlcachenumber urlipcfilename usecustombannedflash \
  92. usecustombannedimage usexforwardedfor weightedphrasemode
  93. validate_e2guardian_section e2guardian || {
  94. echo "validation failed"
  95. return 1
  96. }
  97. mkdir -p $(dirname $CONFIGFILE)
  98. ln -sf $config_file $(dirname $CONFIGFILE)
  99. echo "accessdeniedaddress = " $accessdeniedaddress > $CONFIGFILE
  100. echo "bannediplist = " $bannediplist >> $CONFIGFILE
  101. echo "contentscanexceptions = " $contentscanexceptions >> $CONFIGFILE
  102. echo "contentscannertimeout = " $contentscannertimeout >> $CONFIGFILE
  103. echo "createlistcachefiles = " $createlistcachefiles >> $CONFIGFILE
  104. echo "custombannedflashfile = " $custombannedflashfile >> $CONFIGFILE
  105. echo "custombannedimagefile = " $custombannedimagefile >> $CONFIGFILE
  106. echo "deletedownloadedtempfiles = " $deletedownloadedtempfiles >> $CONFIGFILE
  107. echo "downloadmanager = " $downloadmanager >> $CONFIGFILE
  108. echo "exceptioniplist = " $exceptioniplist >> $CONFIGFILE
  109. echo "filecachedir = " $filecachedir >> $CONFIGFILE
  110. echo "filtergroups = " $filtergroups >> $CONFIGFILE
  111. echo "filtergroupslist = " $filtergroupslist >> $CONFIGFILE
  112. echo "filterip = " $filterip >> $CONFIGFILE
  113. echo "filterports = " $filterports >> $CONFIGFILE
  114. echo "forcequicksearch = " $forcequicksearch >> $CONFIGFILE
  115. echo "forwardedfor = " $forwardedfor >> $CONFIGFILE
  116. echo "hexdecodecontent = " $hexdecodecontent >> $CONFIGFILE
  117. echo "initialtrickledelay = " $initialtrickledelay >> $CONFIGFILE
  118. echo "ipcfilename = " $ipcfilename >> $CONFIGFILE
  119. echo "ipipcfilename = " $ipipcfilename >> $CONFIGFILE
  120. echo "language = " $language >> $CONFIGFILE
  121. echo "languagedir = " $languagedir >> $CONFIGFILE
  122. echo "logadblocks = " $logadblocks >> $CONFIGFILE
  123. echo "logchildprocesshandling = " $logchildprocesshandling >> $CONFIGFILE
  124. echo "logclienthostnames = " $logclienthostnames >> $CONFIGFILE
  125. echo "logconnectionhandlingerrors = " $logconnectionhandlingerrors >> $CONFIGFILE
  126. echo "logexceptionhits = " $logexceptionhits >> $CONFIGFILE
  127. echo "logfileformat = " $logfileformat >> $CONFIGFILE
  128. echo "loglevel = " $loglevel >> $CONFIGFILE
  129. echo "loglocation = " $loglocation >> $CONFIGFILE
  130. echo "loguseragent = " $loguseragent >> $CONFIGFILE
  131. echo "maxagechildren = " $maxagechildren >> $CONFIGFILE
  132. echo "maxchildren = " $maxchildren >> $CONFIGFILE
  133. echo "maxcontentfilecachescansize = " $maxcontentfilecachescansize >> $CONFIGFILE
  134. echo "maxcontentfiltersize = " $maxcontentfiltersize >> $CONFIGFILE
  135. echo "maxcontentramcachescansize = " $maxcontentramcachescansize >> $CONFIGFILE
  136. echo "maxips = " $maxips >> $CONFIGFILE
  137. echo "maxsparechildren = " $maxsparechildren >> $CONFIGFILE
  138. echo "maxuploadsize = " $maxuploadsize >> $CONFIGFILE
  139. echo "minchildren = " $minchildren >> $CONFIGFILE
  140. echo "minsparechildren = " $minsparechildren >> $CONFIGFILE
  141. echo "nodaemon = " $nodaemon >> $CONFIGFILE
  142. echo "nologger = " $nologger >> $CONFIGFILE
  143. echo "pcontimeout = " $pcontimeout >> $CONFIGFILE
  144. echo "perroomdirectory = " $perroomdirectory >> $CONFIGFILE
  145. echo "phrasefiltermode = " $phrasefiltermode >> $CONFIGFILE
  146. echo "prefercachedlists = " $prefercachedlists >> $CONFIGFILE
  147. echo "preforkchildren = " $preforkchildren >> $CONFIGFILE
  148. echo "preservecase = " $preservecase >> $CONFIGFILE
  149. echo "proxyexchange = " $proxyexchange >> $CONFIGFILE
  150. echo "proxyip = " $proxyip >> $CONFIGFILE
  151. echo "proxyport = " $proxyport >> $CONFIGFILE
  152. echo "proxytimeout = " $proxytimeout >> $CONFIGFILE
  153. echo "recheckreplacedurls = " $recheckreplacedurls >> $CONFIGFILE
  154. echo "reverseaddresslookups = " $reverseaddresslookups >> $CONFIGFILE
  155. echo "reverseclientiplookups = " $reverseclientiplookups >> $CONFIGFILE
  156. echo "scancleancache = " $scancleancache >> $CONFIGFILE
  157. echo "showweightedfound = " $showweightedfound >> $CONFIGFILE
  158. echo "softrestart = " $softrestart >> $CONFIGFILE
  159. echo "trickledelay = " $trickledelay >> $CONFIGFILE
  160. echo "urlcacheage = " $urlcacheage >> $CONFIGFILE
  161. echo "urlcachenumber = " $urlcachenumber >> $CONFIGFILE
  162. echo "urlipcfilename = " $urlipcfilename >> $CONFIGFILE
  163. echo "usecustombannedflash = " $usecustombannedflash >> $CONFIGFILE
  164. echo "usecustombannedimage = " $usecustombannedimage >> $CONFIGFILE
  165. echo "usexforwardedfor = " $usexforwardedfor >> $CONFIGFILE
  166. echo "weightedphrasemode = " $weightedphrasemode >> $CONFIGFILE
  167. procd_open_instance
  168. procd_set_param command $PROG -N -c "$CONFIGFILE"
  169. procd_set_param file $CONFIGFILE
  170. procd_set_param respawn
  171. procd_close_instance
  172. }
  173. stop_service()
  174. {
  175. e2guardian -s | awk -F':' '{ print $2}' | xargs kill -9
  176. }
  177. service_triggers()
  178. {
  179. procd_add_reload_trigger "e2guardian"
  180. procd_add_validation validate_e2guardian_section
  181. }