From bda798f966433fcd6feeaadc1abbdc0239bbb502 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 25 Nov 2020 13:58:23 +0300 Subject: [PATCH 1/3] Redure layering --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index dd814a3..6e7d15f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM alpine:3.12 -RUN apk --no-cache add ca-certificates=~20191127-r4 -RUN apk --no-cache add privoxy=~3.0.28-r0 -RUN apk --no-cache add openvpn=~2.4.9-r0 -RUN apk --no-cache add runit=~2.1.2-r3 -RUN apk --no-cache add wget=~1.20.3-r1 -RUN apk --no-cache add unzip=~6.0-r8 +RUN apk --no-cache add ca-certificates=~20191127-r4 \ + && apk --no-cache add privoxy=~3.0.28-r0 \ + && apk --no-cache add openvpn=~2.4.9-r0 \ + && apk --no-cache add runit=~2.1.2-r3 \ + && apk --no-cache add wget=~1.20.3-r1 \ + && apk --no-cache add unzip=~6.0-r8 COPY app /app COPY etc /etc From a01df4520c3d418a785e2dc70aa0d06af832f05d Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 25 Nov 2020 13:58:38 +0300 Subject: [PATCH 2/3] Change download URL and small improvements - Changing default download URL since old one is dead - Add error reporting for dead URL - Since OVPN config file names use snake case, try to convert entries like "US West" into "us_west" for compatibility --- app/ovpn/run | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/ovpn/run b/app/ovpn/run index dd25891..9aa3ae0 100644 --- a/app/ovpn/run +++ b/app/ovpn/run @@ -1,11 +1,14 @@ #!/bin/sh set -e -u -o pipefail +# PIA might change config download URL, if that happens correct it here +PIA_OVPN_CONFIG_URL='https://www.privateinternetaccess.com/openvpn/openvpn-strong-tcp.zip' + [ ! -d /app/ovpn/config ] && mkdir -p /app/ovpn/config # download and install the latest default recommended ovpn configs -wget -q https://www.privateinternetaccess.com/openvpn/openvpn-strong-tcp-nextgen.zip -unzip -uoq openvpn-strong-tcp-nextgen.zip -d /app/ovpn/config -rm -f openvpn-strong-tcp-nextgen.zip +wget -q $PIA_OVPN_CONFIG_URL -O pia_ovpn_configs.zip || (echo "ERROR: Failed to download PIA configuration files, exitting" && exit 1) +unzip -uoq pia_ovpn_configs.zip -d /app/ovpn/config +rm -f pia_ovpn_configs.zip # copy configs to user mount mkdir -p /config/pia @@ -16,9 +19,10 @@ if [ -n "$UID" -a -n "$GID" ]; then fi if [ -n "$REGION" ]; then + REGION=$(echo $REGION | sed 's/ /_/g' | tr '[:upper:]' '[:lower:]') set -- "$@" '--config' "/config/pia/${REGION}.ovpn" else - echo "No OpenVPN config found in /config/pia/${REGION}.ovpn. Exiting." + echo "REGION environment variable is not set. Exiting." exit 1 fi From a2f74d2259cad82e9dbb75862f29bd560b670988 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 25 Nov 2020 18:48:55 +0300 Subject: [PATCH 3/3] Add check if OVPN profile exists --- app/ovpn/run | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/ovpn/run b/app/ovpn/run index 9aa3ae0..45f66d9 100644 --- a/app/ovpn/run +++ b/app/ovpn/run @@ -20,6 +20,10 @@ fi if [ -n "$REGION" ]; then REGION=$(echo $REGION | sed 's/ /_/g' | tr '[:upper:]' '[:lower:]') + if [[ ! -f "/config/pia/${REGION}.ovpn" ]]; then + echo "ERROR: OpenVPN configuration profile not found, check your REGION environment variable, see https://www.privateinternetaccess.com/pages/network/dkrpia for possible choices" + exit 1 + fi set -- "$@" '--config' "/config/pia/${REGION}.ovpn" else echo "REGION environment variable is not set. Exiting."