Tinyproxy variables renamed

This commit is contained in:
Quentin McGaw
2019-09-09 12:40:00 -04:00
parent f4b618cb94
commit aca632ab94
3 changed files with 57 additions and 42 deletions

View File

@@ -31,11 +31,11 @@ ENV USER= \
EXTRA_SUBNETS= \ EXTRA_SUBNETS= \
PORT_FORWARDING=false \ PORT_FORWARDING=false \
PORT_FORWARDING_STATUS_FILE="/forwarded_port" \ PORT_FORWARDING_STATUS_FILE="/forwarded_port" \
PROXY=on \ TINYPROXY=on \
PROXY_LOG_LEVEL=Critical \ TINYPROXY_LOG=Critical \
PROXY_PORT=8888 \ TINYPROXY_PORT=8888 \
PROXY_USER= \ TINYPROXY_USER= \
PROXY_PASSWORD= TINYPROXY_PASSWORD=
ENTRYPOINT /entrypoint.sh ENTRYPOINT /entrypoint.sh
EXPOSE 8888 EXPOSE 8888
HEALTHCHECK --interval=3m --timeout=3s --start-period=20s --retries=1 CMD /healthcheck.sh HEALTHCHECK --interval=3m --timeout=3s --start-period=20s --retries=1 CMD /healthcheck.sh

View File

@@ -158,11 +158,11 @@ docker run --rm --network=container:pia alpine:3.10 wget -qO- https://ipinfo.io
| `EXTRA_SUBNETS` | | comma separated subnets allowed in the container firewall (i.e. `192.168.1.0/24,192.168.10.121,10.0.0.5/28`) | | `EXTRA_SUBNETS` | | comma separated subnets allowed in the container firewall (i.e. `192.168.1.0/24,192.168.10.121,10.0.0.5/28`) |
| `PORT_FORWARDING` | `off` | Set to `on` to forward a port on PIA server | | `PORT_FORWARDING` | `off` | Set to `on` to forward a port on PIA server |
| `PORT_FORWARDING_STATUS_FILE` | `/forwarded_port` | File path to store the forwarded port number | | `PORT_FORWARDING_STATUS_FILE` | `/forwarded_port` | File path to store the forwarded port number |
| `PROXY` | `on` | `on` or `off`, to switch the internal HTTP proxy | | `TINYPROXY` | `on` | `on` or `off`, to enable the internal HTTP proxy tinyproxy |
| `PROXY_LOG_LEVEL` | `Critical` | `Info`, `Warning`, `Error` or `Critical` | | `TINYPROXY_LOG` | `Critical` | `Info`, `Warning`, `Error` or `Critical` |
| `PROXY_PORT` | `8888` | `1024` to `65535` internal port for HTTP proxy | | `TINYPROXY_PORT` | `8888` | `1024` to `65535` internal port for HTTP proxy |
| `PROXY_USER` | | Username to use to connect to the HTTP proxy | | `TINYPROXY_USER` | | Username to use to connect to the HTTP proxy |
| `PROXY_PASSWORD` | | Passsword to use to connect to the HTTP proxy | | `TINYPROXY_PASSWORD` | | Passsword to use to connect to the HTTP proxy |
## Connect to it ## Connect to it

View File

@@ -56,6 +56,21 @@ printf "TinyProxy version: $(tinyproxy -v | cut -d" " -f2)\n"
############################################ ############################################
[ "$PORT_FORWARDING" == "false" ] && PORT_FORWARDING=on [ "$PORT_FORWARDING" == "false" ] && PORT_FORWARDING=on
[ "$PORT_FORWARDING" == "true" ] && PORT_FORWARDING=off [ "$PORT_FORWARDING" == "true" ] && PORT_FORWARDING=off
if [ -z $TINYPROXY && ! -z $PROXY ]; then
TINYPROXY=$PROXY
fi
if [ -z $TINYPROXY_LOG && ! -z $PROXY_LOG_LEVEL ]; then
TINYPROXY_LOG=$PROXY_LOG_LEVEL
fi
if [ -z $TINYPROXY_PORT && ! -z $PROXY_PORT ]; then
TINYPROXY_PORT=$PROXY_PORT
fi
if [ -z $TINYPROXY_USER && ! -z $PROXY_USER ]; then
TINYPROXY_USER=$PROXY_USER
fi
if [ -z $TINYPROXY_PASSWORD && ! -z $PROXY_PASSWORD ]; then
TINYPROXY_PASSWORD=$PROXY_PASSWORD
fi
############################################ ############################################
# CHECK PARAMETERS # CHECK PARAMETERS
@@ -90,26 +105,26 @@ if [ "$PORT_FORWARDING" == "on" && -z "$PORT_FORWARDING_STATUS_FILE" ]; then
printf "PORT_FORWARDING is on but PORT_FORWARDING_STATUS_FILE is not set\n" printf "PORT_FORWARDING is on but PORT_FORWARDING_STATUS_FILE is not set\n"
exit 1 exit 1
fi fi
exitIfNotIn PROXY "on,off" exitIfNotIn TINYPROXY "on,off"
exitIfNotIn PROXY_LOG_LEVEL "Info,Warning,Error,Critical" exitIfNotIn TINYPROXY_LOG "Info,Warning,Error,Critical"
if [ -z $PROXY_PORT ]; then if [ -z $TINYPROXY_PORT ]; then
PROXY_PORT=8888 TINYPROXY_PORT=8888
fi fi
if [ `echo $PROXY_PORT | grep -E "^[0-9]+$"` != $PROXY_PORT ]; then if [ `echo $TINYPROXY_PORT | grep -E "^[0-9]+$"` != $TINYPROXY_PORT ]; then
printf "PROXY_PORT is not a valid number\n" printf "TINYPROXY_PORT is not a valid number\n"
exit 1 exit 1
elif [ $PROXY_PORT -lt 1024 ]; then elif [ $TINYPROXY_PORT -lt 1024 ]; then
printf "PROXY_PORT cannot be a privileged port under port 1024\n" printf "TINYPROXY_PORT cannot be a privileged port under port 1024\n"
exit 1 exit 1
elif [ $PROXY_PORT -gt 65535 ]; then elif [ $TINYPROXY_PORT -gt 65535 ]; then
printf "PROXY_PORT cannot be a port higher than the maximum port 65535\n" printf "TINYPROXY_PORT cannot be a port higher than the maximum port 65535\n"
exit 1 exit 1
fi fi
if [ ! -z "$PROXY_USER" ] && [ -z "$PROXY_PASSWORD" ]; then if [ ! -z "$TINYPROXY_USER" ] && [ -z "$TINYPROXY_PASSWORD" ]; then
printf "PROXY_USER is set but PROXY_PASSWORD is unset\n" printf "TINYPROXY_USER is set but TINYPROXY_PASSWORD is not set\n"
exit 1 exit 1
elif [ -z "$PROXY_USER" ] && [ ! -z "$PROXY_PASSWORD" ]; then elif [ -z "$TINYPROXY_USER" ] && [ ! -z "$TINYPROXY_PASSWORD" ]; then
printf "PROXY_USER is unset but PROXY_PASSWORD is set\n" printf "TINYPROXY_USER is not set but TINYPROXY_PASSWORD is set\n"
exit 1 exit 1
fi fi
@@ -131,15 +146,15 @@ if [ "$DOT" = "on" ]; then
fi fi
printf "Local network parameters:\n" printf "Local network parameters:\n"
printf " * Extra subnets: $EXTRA_SUBNETS\n" printf " * Extra subnets: $EXTRA_SUBNETS\n"
printf " * Web proxy activated: $PROXY\n" printf " * Tinyproxy HTTP proxy: $TINYPROXY\n"
if [ "$PROXY" = "on" ]; then if [ "$TINYPROXY" = "on" ]; then
printf " * Web proxy port: $PROXY_PORT\n" printf " * Tinyproxy port: $TINYPROXY_PORT\n"
proxy_auth=yes tinyproxy_auth=yes
if [ -z $PROXY_USER ]; then if [ -z $TINYPROXY_USER ]; then
proxy_auth=no tinyproxy_auth=no
fi fi
printf " * Web proxy has authentication: $proxy_auth\n" printf " * Tinyproxy has authentication: $tinyproxy_auth\n"
unset -v proxy_auth unset -v tinyproxy_auth
fi fi
printf "PIA parameters:\n" printf "PIA parameters:\n"
printf " * Remote port forwarding: $PORT_FORWARDING\n" printf " * Remote port forwarding: $PORT_FORWARDING\n"
@@ -387,22 +402,22 @@ done
############################################ ############################################
# TINYPROXY LAUNCH # TINYPROXY LAUNCH
############################################ ############################################
if [ "$PROXY" == "on" ]; then if [ "$TINYPROXY" == "on" ]; then
printf "[INFO] Setting TinyProxy log level to $PROXY_LOG_LEVEL..." printf "[INFO] Setting TinyProxy log level to $TINYPROXY_LOG..."
sed -i "/LogLevel /c\LogLevel $PROXY_LOG_LEVEL" /etc/tinyproxy/tinyproxy.conf sed -i "/LogLevel /c\LogLevel $TINYPROXY_LOG" /etc/tinyproxy/tinyproxy.conf
exitOnError $? exitOnError $?
printf "DONE\n" printf "DONE\n"
if [ ! -z "$PROXY_PORT" ]; then if [ ! -z "$TINYPROXY_PORT" ]; then
printf "[INFO] Setting TinyProxy port to $PROXY_PORT..." printf "[INFO] Setting TinyProxy port to $TINYPROXY_PORT..."
sed -i "/Port /c\Port $PROXY_PORT" /etc/tinyproxy/tinyproxy.conf sed -i "/Port /c\Port $TINYPROXY_PORT" /etc/tinyproxy/tinyproxy.conf
exitOnError $? exitOnError $?
printf "DONE\n" printf "DONE\n"
fi fi
if [ ! -z "$PROXY_USER" ]; then if [ ! -z "$TINYPROXY_USER" ]; then
printf "[INFO] Setting TinyProxy credentials..." printf "[INFO] Setting TinyProxy credentials..."
echo "BasicAuth $PROXY_USER $PROXY_PASSWORD" >> /etc/tinyproxy/tinyproxy.conf echo "BasicAuth $TINYPROXY_USER $TINYPROXY_PASSWORD" >> /etc/tinyproxy/tinyproxy.conf
unset -v PROXY_USER unset -v TINYPROXY_USER
unset -v PROXY_PASSWORD unset -v TINYPROXY_PASSWORD
printf "DONE\n" printf "DONE\n"
fi fi
tinyproxy -d & tinyproxy -d &