* Update NordVPN version

* Update error handling
This commit is contained in:
lluked 2023-12-17 13:06:32 +00:00 committed by GitHub
parent c562f6e072
commit 3aa73f4ad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.DS_Store
.env .env

View file

@ -1,15 +1,19 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
ARG NORDVPN_VERSION=${NORDVPN_VERSION:-3.16.5} ARG NORDVPN_VERSION=${NORDVPN_VERSION:-3.16.9}
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y curl iputils-ping wireguard-tools jq && \ apt-get install -y \
curl \
jq \
iputils-ping \
wireguard-tools && \
curl https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb -o "/tmp/nordrepo.deb" && \ curl https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb -o "/tmp/nordrepo.deb" && \
apt-get install -y /tmp/nordrepo.deb && \ apt-get install -y /tmp/nordrepo.deb && \
apt-get update && \ apt-get update && \
apt-get install -y nordvpn${NORDVPN_VERSION:+=$NORDVPN_VERSION} && \ apt-get install -y nordvpn=${NORDVPN_VERSION} && \
apt-get remove -y wget nordvpn-release && \ apt-get remove -y nordvpn-release && \
rm /tmp/nordrepo.deb && \ rm /tmp/nordrepo.deb && \
apt-get clean apt-get clean

View file

@ -1,5 +1,8 @@
#!/bin/bash #!/bin/bash
# Clear the output folder
rm -f -r /output/*
# Get the chosen server # Get the chosen server
api_response=$(curl -s ${API_QUERY:-"https://api.nordvpn.com/v1/servers/recommendations?&filters\[servers_technologies\]\[identifier\]=wireguard_udp&limit=1"}) api_response=$(curl -s ${API_QUERY:-"https://api.nordvpn.com/v1/servers/recommendations?&filters\[servers_technologies\]\[identifier\]=wireguard_udp&limit=1"})
server_identifier=$(jq -r '.[]|.hostname' <<< "$api_response" | cut -d "." -f 1) server_identifier=$(jq -r '.[]|.hostname' <<< "$api_response" | cut -d "." -f 1)
@ -20,9 +23,9 @@ echo "############################################################"
echo "" echo ""
# Get client details # Get client details
nordvpn login --token "${TOKEN}" nordvpn login --token "${TOKEN}" || { echo 'exiting...' ; exit 1; }
nordvpn set technology NordLynx 2>&1 >/dev/null nordvpn set technology NordLynx|| { nordvpn logout --persist-token; echo 'exiting...'; exit 1; }
nordvpn connect "$server_identifier" 2>&1 >/dev/null nordvpn connect "$server_identifier" || { nordvpn logout --persist-token; echo 'exiting...'; exit 1; }
client_private_key=$(wg show nordlynx private-key) client_private_key=$(wg show nordlynx private-key)
client_ip_address=$(ip -o addr show dev nordlynx | awk '$3 == "inet" {print $4}') client_ip_address=$(ip -o addr show dev nordlynx | awk '$3 == "inet" {print $4}')
@ -52,9 +55,10 @@ echo "##################### WireGuard Config #####################"
echo "$config" echo "$config"
echo "############################################################" echo "############################################################"
# Write config # Write config to the putput folder
rm -f -r /output/*
echo "$config" > "/output/nordvpn-$server_identifier.conf" echo "$config" > "/output/nordvpn-$server_identifier.conf"
# Disconnect # Close out
nordvpn disconnect nordvpn disconnect
nordvpn logout --persist-token
exit 0