Healthcheck searches for city and organization of public IP

This commit is contained in:
Quentin McGaw
2018-04-16 14:19:35 -04:00
parent dd99f7e306
commit 73c5fe5b2a
2 changed files with 11 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ LABEL maintainer="quentin.mcgaw@gmail.com" \
ram="11.89MB" \ ram="11.89MB" \
cpu_usage="Low to medium" \ cpu_usage="Low to medium" \
github="https://github.com/qdm12/private-internet-access-docker" github="https://github.com/qdm12/private-internet-access-docker"
RUN apk add -q --progress --no-cache --update openvpn unbound ca-certificates wget && \ RUN apk add -q --progress --no-cache --update openvpn unbound ca-certificates && \
apk add -q --progress --no-cache --update --virtual=build-dependencies unzip && \ apk add -q --progress --no-cache --update --virtual=build-dependencies unzip && \
mkdir /openvpn-udp-normal /openvpn-udp-strong /openvpn-tcp-normal /openvpn-tcp-strong && \ mkdir /openvpn-udp-normal /openvpn-udp-strong /openvpn-tcp-normal /openvpn-tcp-strong && \
wget -q https://www.privateinternetaccess.com/openvpn/openvpn.zip \ wget -q https://www.privateinternetaccess.com/openvpn/openvpn.zip \
@@ -20,7 +20,11 @@ RUN apk add -q --progress --no-cache --update openvpn unbound ca-certificates wg
apk del -q --progress --purge build-dependencies && \ apk del -q --progress --purge build-dependencies && \
rm -rf /*.zip /etc/unbound/unbound.conf /var/cache/apk/* rm -rf /*.zip /etc/unbound/unbound.conf /var/cache/apk/*
COPY unbound.conf /etc/unbound/unbound.conf COPY unbound.conf /etc/unbound/unbound.conf
HEALTHCHECK --interval=10m --timeout=3s --start-period=5s --retries=1 CMD [ $(wget -qO- -T 2 https://api.ipify.org) != "$INITIALIP" ] || exit 1 HEALTHCHECK --interval=10m --timeout=3s --start-period=5s --retries=1 \
CMD VPNCITY=$(wget -qO- -T 2 https://ipinfo.io/city); \
VPNORGANIZATION=$(wget -qO- -T 2 https://ipinfo.io/org); \
printf "\nCity: $VPNCITY\nOrganization: $VPNORGANIZATION"; \
[ "$VPNCITY" != "$CITY" ] || [ "$VPNORGANIZATION" != "$ORGANIZATION" ] || exit 1
ENV ENCRYPTION=strong \ ENV ENCRYPTION=strong \
PROTOCOL=tcp \ PROTOCOL=tcp \
REGION=Switzerland REGION=Switzerland

View File

@@ -1,11 +1,12 @@
#!/bin/sh #!/bin/sh
printf "\nDetecting current public IP address..." printf "\nDetecting details from public IP address..."
export INITIALIP=$(wget -qO- -T 2 https://api.ipify.org) export CITY=$(wget -qO- -T 2 https://ipinfo.io/city)
printf "$INITIALIP\nChanging DNS to localhost..." export ORG=$(wget -qO- -T 2 https://ipinfo.io/org)
printf "DONE\nOrganization: $ORG\nCountry: $COUNTRY\nCity: $CITY\nChanging DNS to localhost..."
echo "nameserver 127.0.0.1" > /etc/resolv.conf echo "nameserver 127.0.0.1" > /etc/resolv.conf
echo "options ndots:0" >> /etc/resolv.conf echo "options ndots:0" >> /etc/resolv.conf
printf "DONE\nStarting Unbound to connect to Cloudflare DNS 1.1.1.1 at its TLS endpoint TCP 853..." printf "DONE\nStarting Unbound to connect to Cloudflare DNS 1.1.1.1 at its TLS endpoint..."
unbound unbound
printf "DONE\nStarting OpenVPN using $PROTOCOL with $ENCRYPTION encryption\n" printf "DONE\nStarting OpenVPN using $PROTOCOL with $ENCRYPTION encryption\n"
DIR=/openvpn-$PROTOCOL-$ENCRYPTION DIR=/openvpn-$PROTOCOL-$ENCRYPTION