Add vpn switching script
This commit is contained in:
parent
8da657ef09
commit
d7106d28d1
32
.config/halia-switch.sh
Executable file
32
.config/halia-switch.sh
Executable file
@ -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
|
2
.zshrc
2
.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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user