summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO11
-rw-r--r--PKGBUILD32
-rwxr-xr-xmake.sh31
-rwxr-xr-xnordvpn64
-rw-r--r--openvpn-nordvpn.install18
5 files changed, 78 insertions, 78 deletions
diff --git a/.SRCINFO b/.SRCINFO
index e8d3b6a14b0a..781f53b57ce6 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,22 +1,21 @@
pkgbase = openvpn-nordvpn
- pkgdesc = OpenVPN configuration files and helper for nordvpn.com
+ pkgdesc = OpenVPN helper script for nordvpn.com
pkgver = 17.5.24
- pkgrel = 10
+ pkgrel = 11
url = http://www.nordvpn.com
install = openvpn-nordvpn.install
arch = any
license = MIT
- makedepends = unzip
makedepends = coreutils
depends = openvpn
depends = systemd
depends = openvpn-update-resolv-conf-git
+ depends = curl
+ depends = unzip
+ depends = coreutils
optdepends = iputils: run ping and rank functions
optdepends = vpnfailsafe-git: use instead of update-resolv-conf if available
provides = nordvpn
- noextract = zip
- source = https://nordvpn.com/api/files/zip
- sha256sums = SKIP
pkgname = openvpn-nordvpn
diff --git a/PKGBUILD b/PKGBUILD
index f10e73f73303..1f46f6a854c9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,42 +2,18 @@
pkgname=openvpn-nordvpn
pkgver=17.5.24
-pkgrel=10
-pkgdesc="OpenVPN configuration files and helper for nordvpn.com"
+pkgrel=11
+pkgdesc="OpenVPN helper script for nordvpn.com"
arch=(any)
url="http://www.nordvpn.com"
license=('MIT')
-depends=('openvpn' 'systemd' 'openvpn-update-resolv-conf-git')
+depends=('openvpn' 'systemd' 'openvpn-update-resolv-conf-git' 'curl' 'unzip' 'coreutils')
optdepends=('iputils: run ping and rank functions'
'vpnfailsafe-git: use instead of update-resolv-conf if available')
-makedepends=('unzip' 'coreutils')
+makedepends=('coreutils')
provides=('nordvpn')
-source=('https://nordvpn.com/api/files/zip')
-noextract=(zip)
-sha256sums=('SKIP')
install=${pkgname}.install
-prepare() {
- test -d conf && rm -rf conf
- mkdir conf
- unzip -q zip -d conf
-}
-
-build() {
- for f in $(find conf -name '*udp1194.ovpn'); do
- sed 's/^auth-user-pass.*$/auth-user-pass \/etc\/openvpn\/client\/nordvpn\/credentials.conf/g' -i $f
- echo "" >> $f
- echo "script-security 2" >> $f
- echo "up /etc/openvpn/client/nordvpn/updown" >> $f
- echo "down /etc/openvpn/client/nordvpn/updown" >> $f
- done
-}
-
package() {
- for f in $(find conf -type f -name '*udp1194.ovpn'); do
- install -D -m 444 $f $pkgdir/etc/openvpn/client/nordvpn/$(basename $f)
- ln -s /etc/openvpn/client/nordvpn/$(basename $f) $pkgdir/etc/openvpn/client/nordvpn_$(echo $(basename $f) | cut -d '.' -f 1).conf
- done
- chmod 750 $pkgdir/etc/openvpn/client
install -D -m 755 ../nordvpn $pkgdir/usr/bin/nordvpn
}
diff --git a/make.sh b/make.sh
deleted file mode 100755
index 821402af9002..000000000000
--- a/make.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-function verify
-{
- git clean -fdx
- makepkg --verifysource
-}
-
-function srcinfo
-{
- makepkg --printsrcinfo > SRCINFO \
- && mv SRCINFO .SRCINFO
-}
-
-case "$1" in
- "srcinfo")
- srcinfo
- ;;
- "verify")
- verify
- ;;
- "update")
- verify || (updpkgsums \
- && sed -e "s/^\(pkgver=\).*/\1$(date +%y.%m.%d)/g" \
- -e "s/\.0/\./g" \
- -i PKGBUILD \
- && srcinfo \
- && git add PKGBUILD .SRCINFO \
- && git commit -m "Update src checksum")
- ;;
-esac
diff --git a/nordvpn b/nordvpn
index 99c065243ebe..7be0ca5be6a8 100755
--- a/nordvpn
+++ b/nordvpn
@@ -12,6 +12,65 @@ run_ping() {
$bin -c 4 -A $remote | tail -n 1 | cut -d / -f 5
}
+progress_bar()
+{
+ pct=$(echo "${1} / ${2}" | bc -l)
+ hashes=$(printf "%0.s#" $(seq $(echo "$pct * 73 + 1" | bc )))
+ spaces=$(printf "%0.s " $(seq $(echo "(1 - $pct) * 73" | bc)))
+ printf "\r%s%s %5.1f%%" "$hashes" "$spaces" "$(echo "$pct * 100" | bc)"
+}
+
+end_progress_bar()
+{
+ hashes=$(printf "%0.s#" $(seq 73))
+ printf "\r%s 100.0%%\n" "$hashes"
+}
+
+update_files()
+{
+ local targetdir=/etc/openvpn/client/nordvpn
+ mkdir -p $targetdir
+ local tmpdir=$(mktemp -d)
+ cd $tmpdir
+
+ echo "Downloading nordvpn config files..."
+ curl --progress-bar -o nordvpn.zip https://nordvpn.com/api/files/zip || exit 1
+ # cp ~nicolas/abs/openvpn-nordvpn/zip nordvpn.zip || exit 1
+ mkdir conf
+ unzip -q nordvpn.zip -d conf || exit 2
+
+ echo "Patching and installing files..."
+ test -f $targetdir/credentials.conf && cp $targetdir/credentials.conf .
+ find /etc/openvpn/client -name 'nordvpn_*.conf' | xargs -r rm
+ rm -rf $targetdir/conf && mkdir -p $targetdir/conf
+
+ nb_files=$(find conf -name '*udp1194.ovpn' | wc -l)
+ idx=0
+ for f in $(find conf -name '*udp1194.ovpn'); do
+ progress_bar $idx $nb_files
+ sed 's/^auth-user-pass.*$/auth-user-pass \/etc\/openvpn\/client\/nordvpn\/credentials.conf/g' -i $f
+ echo "" >> $f
+ echo "script-security 2" >> $f
+ echo "up /etc/openvpn/client/nordvpn/updown" >> $f
+ echo "down /etc/openvpn/client/nordvpn/updown" >> $f
+ install -D -m 444 $f $targetdir/conf/$(basename $f)
+ ln -s $targetdir/conf/$(basename $f) /etc/openvpn/client/nordvpn_$(echo $(basename $f) | cut -d '.' -f 1).conf
+ idx=$(( $idx + 1 ))
+ done
+ end_progress_bar
+
+ if [ -f credentials.conf ]; then
+ cp credentials.conf /etc/openvpn/client/nordvpn/credentials.conf
+ else
+ echo "login" > /etc/openvpn/client/nordvpn/credentials.conf
+ echo "password" >> /etc/openvpn/client/nordvpn/credentials.conf
+ chmod 400 /etc/openvpn/client/nordvpn/credentials.conf
+ echo "Please update /etc/openvpn/client/nordvpn/credentials.conf"
+ fi
+
+ rm -rf $tmpdir
+}
+
print_usage() {
echo "usage: $(basename $0) [options] command [args]"
echo "Available options:"
@@ -28,6 +87,8 @@ print_usage() {
echo " Show current systemd service status, if any."
echo " start|stop|restart server_name"
echo " Start, stop or restart systemd service for specified server."
+ echo " update"
+ echo " Download and install nordvpn config files."
}
while getopts "vh" opt
@@ -91,6 +152,9 @@ case $command in
service=$(get_service)
test -z "$service" || systemctl $command $service
;;
+ update)
+ update_files
+ ;;
*)
print_usage
exit 1
diff --git a/openvpn-nordvpn.install b/openvpn-nordvpn.install
index 4ae9aa943d63..317ee7b329a0 100644
--- a/openvpn-nordvpn.install
+++ b/openvpn-nordvpn.install
@@ -1,24 +1,16 @@
-create_credentials() {
- if [ ! -f /etc/openvpn/client/nordvpn/credentials.conf ]; then
- echo "login" > /etc/openvpn/client/nordvpn/credentials.conf
- echo "password" >> /etc/openvpn/client/nordvpn/credentials.conf
- chmod 400 /etc/openvpn/client/nordvpn/credentials.conf
- echo "Please update /etc/openvpn/client/nordvpn/credentials.conf"
- fi
+pre_remove() {
+ nordvpn stop
}
post_install() {
- create_credentials
+ nordvpn update
}
post_upgrade() {
- create_credentials
-}
-
-pre_remove() {
- nordvpn stop
+ nordvpn update
}
post_remove() {
rm -rf /etc/openvpn/client/nordvpn
+ find /etc/openvpn/client -name 'nordvpn_*.conf' | xargs -r rm
}