-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
67 lines (54 loc) · 1.2 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env sh
set -e
CONFIG="/app/proxy.conf"
function writeConfig() {
cat << EOF >> "$CONFIG"
User $TINYPROXY_UID
Group $TINYPROXY_GID
Port $PORT
Timeout $TIMEOUT
DefaultErrorFile "/usr/share/tinyproxy/default.html"
StatHost "tinyproxy.stats"
StatFile "/usr/share/tinyproxy/stats.html"
LogLevel $LOGLEVEL
MaxClients $MAXCLIENTS
ViaProxyName "Swarmproxy"
Allow 127.0.0.1/8
Allow 10.0.0.0/8
EOF
}
function addUpstreamConfig() {
[ -z "$UPSTREAM_PROXY_FILE" ] || export UPSTREAM_PROXY=$(cat $UPSTREAM_PROXY_FILE)
[ -z "$UPSTREAM_PROXY" ] || echo "Upstream http $UPSTREAM_PROXY " >> "$CONFIG"
}
function addFilterConfig() {
if [ -f "$FILTER_FILE" ]; then
cat << FBLOCK >> "$CONFIG"
Filter "$FILTER_FILE"
FilterURLs Off
FilterCaseSensitive Off
FilterDefaultDeny Yes
FBLOCK
else
echo "🦁 FILTER_FILE not found or set."
fi
}
function showConfig() {
echo "🦁 Final Swarmproxy config 🦁"
cat "$CONFIG"
}
function execTinyproxy() {
echo "🦁 Starting Tinyproxy..."
echo "args count: $#"
echo "args value: $@"
exec "/usr/bin/tinyproxy" "$@"
}
function main() {
writeConfig
addUpstreamConfig
addFilterConfig
showConfig
execTinyproxy $@
}
main $@
echo "entrypoint end. 🚀"