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