Merge pull request #840 from cjkoenig/update_liburcu
[feed/packages.git] / net / e2guardian / files / e2guardian.init
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
11 validate_e2guardian_section() {
12 uci_validate_section e2guardian e2guardian "${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,6)' \
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 'pcontimeout:range(5,300)' \
59 'perroomdirectory:string' \
60 'phrasefiltermode:range(0,3)' \
61 'prefercachedlists:string' \
62 'preforkchildren:uinteger' \
63 'preservecase:range(0,2)' \
64 'proxyexchange:range(20,300)' \
65 'proxyip:ipaddr' \
66 'proxyport:port:3128' \
67 'proxytimeout:range(5,100)' \
68 'recheckreplacedurls:string' \
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
86 local config_file accessdeniedaddress bannediplist contentscanexceptions contentscannertimeout \
87 createlistcachefiles custombannedflashfile custombannedimagefile deletedownloadedtempfiles \
88 downloadmanager exceptioniplist filecachedir loglocation \
89 filtergroups filtergroupslist filterip filterports forcequicksearch forwardedfor hexdecodecontent \
90 initialtrickledelay ipcfilename ipipcfilename language languagedir logadblocks logchildprocesshandling \
91 logclienthostnames logconnectionhandlingerrors logexceptionhits logfileformat loglevel loguseragent \
92 maxagechildren maxchildren maxcontentfilecachescansize maxcontentfiltersize maxcontentramcachescansize \
93 maxips maxsparechildren maxuploadsize minchildren minsparechildren nodaemon nologger \
94 pcontimeout perroomdirectory phrasefiltermode prefercachedlists preforkchildren preservecase proxyexchange \
95 proxyip proxyport proxytimeout recheckreplacedurls reverseaddresslookups reverseclientiplookups scancleancache \
96 showweightedfound softrestart trickledelay urlcacheage urlcachenumber urlipcfilename usecustombannedflash \
97 usecustombannedimage usexforwardedfor weightedphrasemode
98
99 validate_e2guardian_section e2guardian || {
100 echo "validation failed"
101 return 1
102 }
103
104 mkdir -p $(dirname $CONFIGFILE)
105 ln -sf $config_file $(dirname $CONFIGFILE)
106
107 echo "accessdeniedaddress = " $accessdeniedaddress > $CONFIGFILE
108 echo "bannediplist = " $bannediplist >> $CONFIGFILE
109 echo "contentscanexceptions = " $contentscanexceptions >> $CONFIGFILE
110 echo "contentscannertimeout = " $contentscannertimeout >> $CONFIGFILE
111 echo "createlistcachefiles = " $createlistcachefiles >> $CONFIGFILE
112 echo "custombannedflashfile = " $custombannedflashfile >> $CONFIGFILE
113 echo "custombannedimagefile = " $custombannedimagefile >> $CONFIGFILE
114 echo "deletedownloadedtempfiles = " $deletedownloadedtempfiles >> $CONFIGFILE
115 echo "downloadmanager = " $downloadmanager >> $CONFIGFILE
116 echo "exceptioniplist = " $exceptioniplist >> $CONFIGFILE
117 echo "filecachedir = " $filecachedir >> $CONFIGFILE
118 echo "filtergroups = " $filtergroups >> $CONFIGFILE
119 echo "filtergroupslist = " $filtergroupslist >> $CONFIGFILE
120 echo "filterip = " $filterip >> $CONFIGFILE
121 echo "filterports = " $filterports >> $CONFIGFILE
122 echo "forcequicksearch = " $forcequicksearch >> $CONFIGFILE
123 echo "forwardedfor = " $forwardedfor >> $CONFIGFILE
124 echo "hexdecodecontent = " $hexdecodecontent >> $CONFIGFILE
125 echo "initialtrickledelay = " $initialtrickledelay >> $CONFIGFILE
126 echo "ipcfilename = " $ipcfilename >> $CONFIGFILE
127 echo "ipipcfilename = " $ipipcfilename >> $CONFIGFILE
128 echo "language = " $language >> $CONFIGFILE
129 echo "languagedir = " $languagedir >> $CONFIGFILE
130 echo "logadblocks = " $logadblocks >> $CONFIGFILE
131 echo "logchildprocesshandling = " $logchildprocesshandling >> $CONFIGFILE
132 echo "logclienthostnames = " $logclienthostnames >> $CONFIGFILE
133 echo "logconnectionhandlingerrors = " $logconnectionhandlingerrors >> $CONFIGFILE
134 echo "logexceptionhits = " $logexceptionhits >> $CONFIGFILE
135 echo "logfileformat = " $logfileformat >> $CONFIGFILE
136 echo "loglevel = " $loglevel >> $CONFIGFILE
137 echo "loglocation = " $loglocation >> $CONFIGFILE
138 echo "loguseragent = " $loguseragent >> $CONFIGFILE
139 echo "maxagechildren = " $maxagechildren >> $CONFIGFILE
140 echo "maxchildren = " $maxchildren >> $CONFIGFILE
141 echo "maxcontentfilecachescansize = " $maxcontentfilecachescansize >> $CONFIGFILE
142 echo "maxcontentfiltersize = " $maxcontentfiltersize >> $CONFIGFILE
143 echo "maxcontentramcachescansize = " $maxcontentramcachescansize >> $CONFIGFILE
144 echo "maxips = " $maxips >> $CONFIGFILE
145 echo "maxsparechildren = " $maxsparechildren >> $CONFIGFILE
146 echo "maxuploadsize = " $maxuploadsize >> $CONFIGFILE
147 echo "minchildren = " $minchildren >> $CONFIGFILE
148 echo "minsparechildren = " $minsparechildren >> $CONFIGFILE
149 echo "nodaemon = " $nodaemon >> $CONFIGFILE
150 echo "nologger = " $nologger >> $CONFIGFILE
151 echo "pcontimeout = " $pcontimeout >> $CONFIGFILE
152 echo "perroomdirectory = " $perroomdirectory >> $CONFIGFILE
153 echo "phrasefiltermode = " $phrasefiltermode >> $CONFIGFILE
154 echo "prefercachedlists = " $prefercachedlists >> $CONFIGFILE
155 echo "preforkchildren = " $preforkchildren >> $CONFIGFILE
156 echo "preservecase = " $preservecase >> $CONFIGFILE
157 echo "proxyexchange = " $proxyexchange >> $CONFIGFILE
158 echo "proxyip = " $proxyip >> $CONFIGFILE
159 echo "proxyport = " $proxyport >> $CONFIGFILE
160 echo "proxytimeout = " $proxytimeout >> $CONFIGFILE
161 echo "recheckreplacedurls = " $recheckreplacedurls >> $CONFIGFILE
162 echo "reverseaddresslookups = " $reverseaddresslookups >> $CONFIGFILE
163 echo "reverseclientiplookups = " $reverseclientiplookups >> $CONFIGFILE
164 echo "scancleancache = " $scancleancache >> $CONFIGFILE
165 echo "showweightedfound = " $showweightedfound >> $CONFIGFILE
166 echo "softrestart = " $softrestart >> $CONFIGFILE
167 echo "trickledelay = " $trickledelay >> $CONFIGFILE
168 echo "urlcacheage = " $urlcacheage >> $CONFIGFILE
169 echo "urlcachenumber = " $urlcachenumber >> $CONFIGFILE
170 echo "urlipcfilename = " $urlipcfilename >> $CONFIGFILE
171 echo "usecustombannedflash = " $usecustombannedflash >> $CONFIGFILE
172 echo "usecustombannedimage = " $usecustombannedimage >> $CONFIGFILE
173 echo "usexforwardedfor = " $usexforwardedfor >> $CONFIGFILE
174 echo "weightedphrasemode = " $weightedphrasemode >> $CONFIGFILE
175
176 procd_open_instance
177 procd_set_param command $PROG -N -c "$CONFIGFILE"
178 procd_set_param file $CONFIGFILE
179 procd_set_param respawn
180 procd_close_instance
181 }
182
183 stop_service()
184 {
185 e2guardian -s | awk -F':' '{ print $2}' | xargs kill -9
186 }
187
188 service_triggers()
189 {
190 procd_add_reload_trigger "e2guardian"
191 procd_add_validation validate_e2guardian_section
192 }