|
@@ -0,0 +1,150 @@
|
|
1
|
+#!/bin/sh /etc/rc.common
|
|
2
|
+# Copyright (C) 2008-2011 OpenWrt.org
|
|
3
|
+
|
|
4
|
+START=99
|
|
5
|
+
|
|
6
|
+CFGFILE=/var/etc/polipo.conf
|
|
7
|
+
|
|
8
|
+start() {
|
|
9
|
+ config_load 'polipo'
|
|
10
|
+
|
|
11
|
+ config_get_bool enabled "general" 'enabled' '0'
|
|
12
|
+ [ $enabled -gt 0 ] || return 1
|
|
13
|
+
|
|
14
|
+ mkdir -m 0755 -p /var/etc/
|
|
15
|
+ echo '### AUTOGENERATED CONFIGURATION' > $CFGFILE
|
|
16
|
+ echo '### DO NOT EDIT' >> $CFGFILE
|
|
17
|
+ echo '### SEE /etc/config/polipo INSTEAD' >> $CFGFILE
|
|
18
|
+ echo '' >> $CFGFILE
|
|
19
|
+
|
|
20
|
+ config_foreach polipo_config 'polipo'
|
|
21
|
+
|
|
22
|
+ # handle values that are disabled when not defined or empty
|
|
23
|
+ echo "### VALUES THAT ARE DISABLED WHEN EMPTY" >> $CFGFILE
|
|
24
|
+ polipo_atom "cache" "diskCacheRoot" '"' "1" >> $CFGFILE
|
|
25
|
+ polipo_atom "general" "logFile" '"' "1" >> $CFGFILE
|
|
26
|
+ polipo_atom "general" "localDocumentRoot" '"' "1" >> $CFGFILE
|
|
27
|
+
|
|
28
|
+ service_start /usr/sbin/polipo -c "$CFGFILE"
|
|
29
|
+}
|
|
30
|
+
|
|
31
|
+stop() {
|
|
32
|
+ service_stop /usr/sbin/polipo -c "$CFGFILE"
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+polipo_config() {
|
|
36
|
+ echo "### SECTION $1" >> $CFGFILE
|
|
37
|
+
|
|
38
|
+ string_options='authCredentials authRealm dnsNameServer forbiddenFile
|
|
39
|
+ forbiddenUrl logFacility pidFile parentAuthCredentials parentProxy
|
|
40
|
+ proxyAddress proxyName redirector socksParentProxy socksProxyType
|
|
41
|
+ socksUserName uncachableFile'
|
|
42
|
+
|
|
43
|
+ number_options='bigBufferSize chunkCriticalMark chunkHighMark chunkLowMark
|
|
44
|
+ diskCacheDirectoryPermissions diskCacheFilePermissions
|
|
45
|
+ diskCacheTruncateSize diskCacheWriteoutOnClose forbiddenRedirectCode
|
|
46
|
+ logFilePermissions logLevel maxDiskCacheEntrySize maxDiskEntries
|
|
47
|
+ maxObjectsWhenIdle maxPipelineTrain maxSideBuffering maxWriteoutWhenIdle
|
|
48
|
+ objectHashTableSize objectHighMark pmmFirstSize pmmSize proxyPort
|
|
49
|
+ publicObjectLowMark redirectorRedirectCode replyUnpipelineSize
|
|
50
|
+ serverMaxSlots serverSlots serverSlots1 maxAgeFraction'
|
|
51
|
+
|
|
52
|
+ time_options='clientTimeout diskCacheTruncateTime diskCacheUnlinkTime
|
|
53
|
+ dnsGethostbynameTtl dnsMaxTimeout dnsNegativeTtl idleTime maxAge
|
|
54
|
+ maxConnectionAge maxConnectionRequests maxExpiresAge maxNoModifiedAge
|
|
55
|
+ replyUnpipelineTime serverExpireTime serverIdleTimeout serverTimeout
|
|
56
|
+ smallRequestTime'
|
|
57
|
+
|
|
58
|
+ multistate_options='censorReferer dnsQueryIPv6 dnsUseGethostbyname
|
|
59
|
+ dontTrustVaryETag expectContinue pipelineAdditionalRequests
|
|
60
|
+ useTemporarySourceAddress relaxTransparency'
|
|
61
|
+
|
|
62
|
+ boolean_options='cacheIsShared daemonise disableConfiguration disableIndexing
|
|
63
|
+ disableLocalInterface disableProxy disableServersList disableVia
|
|
64
|
+ dontCacheCookies dontCacheRedirects logSyslog mindlesslyCacheVary
|
|
65
|
+ preciseExpiry proxyOffline scrubLogs laxHttpParser'
|
|
66
|
+
|
|
67
|
+ string_list_options='allowedClients censoredHeaders'
|
|
68
|
+
|
|
69
|
+ number_list_options='allowedPorts tunnelAllowedPorts'
|
|
70
|
+
|
|
71
|
+ for option in $string_options; do
|
|
72
|
+ polipo_atom "$1" "$option" '"' >> $CFGFILE
|
|
73
|
+ done
|
|
74
|
+
|
|
75
|
+ for option in $number_options; do
|
|
76
|
+ polipo_atom "$1" "$option" >> $CFGFILE
|
|
77
|
+ done
|
|
78
|
+
|
|
79
|
+ for option in $time_options; do
|
|
80
|
+ polipo_atom "$1" "$option" >> $CFGFILE
|
|
81
|
+ done
|
|
82
|
+
|
|
83
|
+ for option in $multistate_options; do
|
|
84
|
+ polipo_atom "$1" "$option" >> $CFGFILE
|
|
85
|
+ done
|
|
86
|
+
|
|
87
|
+ for option in $boolean_options; do
|
|
88
|
+ polipo_boolean "$1" "$option" >> $CFGFILE
|
|
89
|
+ done
|
|
90
|
+
|
|
91
|
+ for option in $string_list_options; do
|
|
92
|
+ polipo_list "$1" "$option" '"' >> $CFGFILE
|
|
93
|
+ done
|
|
94
|
+
|
|
95
|
+ for option in $number_list_options; do
|
|
96
|
+ polipo_list "$1" "$option" >> $CFGFILE
|
|
97
|
+ done
|
|
98
|
+}
|
|
99
|
+
|
|
100
|
+polipo_atom() {
|
|
101
|
+ local SECTION=$1
|
|
102
|
+ local OPTION=$2
|
|
103
|
+ local QUOTE=$3
|
|
104
|
+ local EMPTY_DISABLED=${4:-0}
|
|
105
|
+
|
|
106
|
+ config_get _value "$SECTION" "$OPTION"
|
|
107
|
+ [ -n "$_value" -o "$EMPTY_DISABLED" -eq "1" ] && {
|
|
108
|
+ echo "$OPTION = ${QUOTE}${_value}${QUOTE}"
|
|
109
|
+ }
|
|
110
|
+}
|
|
111
|
+
|
|
112
|
+polipo_boolean() {
|
|
113
|
+ local SECTION=$1
|
|
114
|
+ local OPTION=$2
|
|
115
|
+
|
|
116
|
+ config_get_bool _value "$SECTION" "$OPTION"
|
|
117
|
+ [ -n "$_value" ] && {
|
|
118
|
+ [ "$_value" -eq "1" ] && _value="true" || _value="false"
|
|
119
|
+ echo "$OPTION = $_value"
|
|
120
|
+ }
|
|
121
|
+}
|
|
122
|
+
|
|
123
|
+polipo_list() {
|
|
124
|
+ local SECTION=$1
|
|
125
|
+ local OPTION=$2
|
|
126
|
+ local QUOTE=$3
|
|
127
|
+
|
|
128
|
+ config_get _value "$SECTION" "$OPTION"
|
|
129
|
+
|
|
130
|
+ [ "$SECTION" = general ] && [ "$OPTION" = allowedClients ] && {
|
|
131
|
+ case "$_value" in
|
|
132
|
+ *127.0.0.1*) : ;;
|
|
133
|
+ *) _value="127.0.0.1 $_value" ;;
|
|
134
|
+ esac
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ [ -n "$_value" ] && {
|
|
138
|
+ echo -n "$OPTION = "
|
|
139
|
+
|
|
140
|
+ local FIRST=1
|
|
141
|
+ for entry in $_value; do
|
|
142
|
+ [ "$FIRST" -ne "1" ] && echo -n ", " || FIRST=0
|
|
143
|
+
|
|
144
|
+ echo -n "${QUOTE}${entry}${QUOTE}"
|
|
145
|
+ done
|
|
146
|
+
|
|
147
|
+ echo ''
|
|
148
|
+ }
|
|
149
|
+}
|
|
150
|
+
|