diff --git a/.config/halia-switch.sh b/.config/halia-switch.sh new file mode 100755 index 0000000..f78795d --- /dev/null +++ b/.config/halia-switch.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +trap "exit" INT + +printf "Checking for sudo privileges...\n"; +sudo -n true &> /dev/null; + +if [ "$?" -eq "0" ]; then + printf "Running in a session with sudo privileges, continuing\n"; +else + printf "This scripts need sudo privileges to continue\n"; + sudo ls &> /dev/null; +fi + +printf "Checking for current VPN configuration...\n"; +ip addr show halia &> /dev/null; + +if [ "$?" -eq "0" ]; then + printf "Found partial connection, switching...\n"; + printf "Disabling halia partial...\n"; + wg-quick down halia &> /dev/null; + printf "Starting halia-full...\n"; + wg-quick up halia-full &> /dev/null; + printf "Successfully switched to full VPN connection\n"; +else + printf "Found full connection, switching...\n"; + printf "Disabling halia-full...\n"; + wg-quick down halia-full &> /dev/null; + printf "Starting halia partial...\n"; + wg-quick up halia &> /dev/null; + printf "Successfully switched to partial VPN connection\n"; +fi diff --git a/.zshrc b/.zshrc index b360955..a150c57 100644 --- a/.zshrc +++ b/.zshrc @@ -174,6 +174,8 @@ alias tlmgr='/usr/share/texmf-dist/scripts/texlive/tlmgr.pl --usermode' alias gitcommiiiiiiiiiiiiiit='cz' +alias havpn='~/.config/halia-switch.sh' + # The next line updates PATH for the Google Cloud SDK. if [ -f '/home/tanguy/Downloads/tmp/google-cloud-sdk/path.zsh.inc' ]; then . '/home/tanguy/Downloads/tmp/google-cloud-sdk/path.zsh.inc'; fi