-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·26 lines (21 loc) · 889 Bytes
/
entrypoint.sh
File metadata and controls
executable file
·26 lines (21 loc) · 889 Bytes
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
#!/bin/sh
FILTER_FILE="/tmp/tinyproxy/filter"
CONFIG_FILE="/tmp/tinyproxy/tinyproxy.conf" # We use tmp directory to be able to run with non-root user.
USER_CONFIG_FILE="/etc/tinyproxy/tinyproxy.conf"
DEFAULT_CONFIG_FILE="/etc/tinyproxy/tinyproxy.default.conf"
mkdir -p /tmp/tinyproxy
if [ -f "$USER_CONFIG_FILE" ]; then # If the config file exists, use the existing one. Otherwise, use the default one.
cp "$USER_CONFIG_FILE" "$CONFIG_FILE"
else
cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE"
sed -i "s|^Allow |#Allow |" "$CONFIG_FILE"
if [ ! -z $ALLOWED_HOSTS ]; then
sed -i "s|^#Filter .*|Filter \"${FILTER_FILE}\"|" "$CONFIG_FILE"
sed -i "s|^#FilterDefaultDeny .*|FilterDefaultDeny Yes|" "$CONFIG_FILE"
touch $FILTER_FILE
for host in $(echo $ALLOWED_HOSTS | tr ',' '\n'); do
echo "$host" >> "$FILTER_FILE"
done
fi
fi
exec tinyproxy -d -c $CONFIG_FILE