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.

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