home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 882dce1df6bf9a8c8f15bcdf41bb11966ed4f198
parent 3a65aa249616b8deb812904ac1d318c99e5bac10
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Thu,  4 Jul 2019 13:54:48 +0200

script: make redhat-vpn smarter

- do not try to re-connect if already connected
- display some notifications

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mpkgs/scripts/bin/redhat-vpn | 26+++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/pkgs/scripts/bin/redhat-vpn b/pkgs/scripts/bin/redhat-vpn @@ -4,14 +4,22 @@ # do some magic set -e export BEMENU_BACKEND=curses -connection=$(nmcli connection show | grep vpn | nix run nixpkgs.bemenu -c bemenu | awk '{print $3}') -key=$(authkey) +connection=$(nmcli connection show | grep vpn | nix run nixpkgs.bemenu -c bemenu) +uuid=$(echo ${connection} | awk '{print $3}') +name=$(echo ${connection} | awk '{print $1 $2}') +VPNSTATUS=$(nmcli connection show --active $uuid | wc -l) +if [ "$VPNSTATUS" == "0" ] +then + key=$(authkey) + passfile=$(mktemp) -passfile=$(mktemp) + echo -n "vpn.secrets.password:" > $passfile + gpg --decrypt $HOME/desktop/documents/Red\ Hat/naruhodo.pass.gpg 2>/dev/null >>$passfile + echo -n "${key}" >> $passfile -echo -n "vpn.secrets.password:" > $passfile -gpg --decrypt $HOME/desktop/documents/Red\ Hat/naruhodo.pass.gpg 2>/dev/null >>$passfile -echo -n "${key}" >> $passfile - -nmcli connection up ${connection} passwd-file $passfile -rm $passfile + nmcli connection up ${connection} passwd-file $passfile + rm $passfile + notify-send "VPN ${name} is connected." "You are now connected to the Red Hat VPN, let's work !" +else + notify-send "VPN ${name} is already connected." "You are already connected to the Red Hat VPN, let's work !" +fi