lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

e2guardian.init (8540B)


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