diff options
author | Nicolas Stinus | 2017-06-01 22:52:03 +0800 |
---|---|---|
committer | Nicolas Stinus | 2017-06-01 22:52:03 +0800 |
commit | 3ee48d7ad679d38b1eccd290e24af940df2072f8 (patch) | |
tree | 53d9bcd521908829a6c7349607e36d9a0d160e94 | |
parent | 99e7009fc42652d32ba0693482cba04344cf6f5c (diff) | |
download | aur-3ee48d7ad679d38b1eccd290e24af940df2072f8.tar.gz |
Fix previous commit and use latest upstream version (update only if needed)
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 6 | ||||
-rwxr-xr-x | nordvpn | 162 |
3 files changed, 5 insertions, 167 deletions
@@ -1,6 +1,6 @@ pkgbase = openvpn-nordvpn pkgdesc = OpenVPN helper script for nordvpn.com - pkgver = 17.5.25 + pkgver = 17.6.1 pkgrel = 12 url = https://github.com/nstinus/nordvpn install = openvpn-nordvpn.install @@ -16,7 +16,7 @@ pkgbase = openvpn-nordvpn optdepends = iputils: run ping and rank functions optdepends = vpnfailsafe-git: use instead of update-resolv-conf if available provides = nordvpn - source = https://github.com/nstinus/nordvpn.git#8bedcb2 + source = git+https://github.com/nstinus/nordvpn.git#commit=2cff124 sha1sums = SKIP pkgname = openvpn-nordvpn @@ -1,7 +1,7 @@ # Maintainer: Nicolas Stinus <nicolas.stinus@gmail.com> pkgname=openvpn-nordvpn -pkgver=17.5.25 +pkgver=17.6.1 pkgrel=12 pkgdesc="OpenVPN helper script for nordvpn.com" arch=(any) @@ -12,10 +12,10 @@ optdepends=('iputils: run ping and rank functions' 'vpnfailsafe-git: use instead of update-resolv-conf if available') makedepends=('coreutils') provides=('nordvpn') -source=('https://github.com/nstinus/nordvpn.git#8bedcb2') +source=('git+https://github.com/nstinus/nordvpn.git#commit=2cff124') sha1sums=('SKIP') install=${pkgname}.install package() { - install -D -m 755 ../nordvpn $pkgdir/usr/bin/nordvpn + install -D -m 755 nordvpn/nordvpn $pkgdir/usr/bin/nordvpn } diff --git a/nordvpn b/nordvpn deleted file mode 100755 index 7be0ca5be6a8..000000000000 --- a/nordvpn +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/sh - -get_service() { - systemctl --type=service | grep openvpn-client@nordvpn | awk '{print $1}' -} - -run_ping() { - remote=$(grep -E '^remote [0-9.]+ [0-9]+$' $1 | cut -d ' ' -f 2) - test ! -z "$remote" || exit 1 - bin=$(which ping) - test $? -eq 0 || echo "ping not found, please install iputils" - $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:" - echo " -v be verbose, show commands and variables" - echo " -h print this help and exit" - echo "Available commands:" - echo " list [server_name_pattern]" - echo " List available servers." - echo " ping server_name" - echo " Show round trip latency" - echo " rank [server_name_pattern]" - echo " Ping all servers matching pattern and rank them" - echo " status" - 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 -do - case $opt in - v) - set -x - shift - ;; - *) - print_usage - exit $(test $opt == "h") - ;; - esac -done - -command=$1 -shift - -case $command in - list) - find /etc/openvpn/client/ -type l -name "nordvpn_*${1}*.conf" \ - | xargs -L1 basename \ - | cut -d _ -f 2 \ - | cut -d . -f 1 \ - | sort -g - ;; - ping) - file=/etc/openvpn/client/nordvpn_${1}.conf - test -f "$file" || exit 1 - run_ping $file - ;; - rank) - tmp=$(mktemp) - for f in $(find /etc/openvpn/client/ -type l -name "nordvpn_*${1}*.conf") - do - echo $(basename $f .conf | cut -d _ -f 2) $(run_ping $f) >> $tmp - done - sort -k 2 -n $tmp - rm -f $tmp - ;; - status) - service=$(get_service) - test -z "$service" || systemctl status $service - ;; - start) - service=$(get_service) - test -z "$service" || $0 stop - if [[ -x /etc/openvpn/vpnfailsafe.sh ]]; then - ln -fs /etc/openvpn/vpnfailsafe.sh /etc/openvpn/client/nordvpn/updown - else - ln -fs /etc/openvpn/update-resolv-conf /etc/openvpn/client/nordvpn/updown - fi - if [[ ! -f /etc/openvpn/client/nordvpn_${1}.conf ]]; then - echo "${1} is not a valid nordvpn server. Exiting." - exit 1 - fi - systemctl $command openvpn-client@nordvpn_${1} - ;; - stop|restart) - service=$(get_service) - test -z "$service" || systemctl $command $service - ;; - update) - update_files - ;; - *) - print_usage - exit 1 - ;; -esac |