Add wgup and wgdown scripts

This commit is contained in:
Rob Watson 2021-03-31 21:34:50 +02:00
parent 679986a1af
commit c18520d423
3 changed files with 33 additions and 0 deletions

15
script/wgdown Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# deactivate all wireguard interfaces; requires sudo
set -e
if [[ $euid > 0 ]]; then
echo "requires administrative privileges"
exit 1
fi
wg | grep interface: | grep -oP '([-\w]+)$' | while read -r iface ; do
echo "iface $iface down..."
wg-quick down "$iface"
done

15
script/wgup Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# select and active wireguard interface; requires sudo
set -e
if [[ $euid > 0 ]]; then
echo "requires administrative privileges"
exit 1
fi
defaultquery="es1"
conffile=$(find /etc/wireguard -type f -name '*.conf' | sort | fzf -q "$defaultquery")
config=$(basename "$conffile" ".conf")
wg-quick up "$config"

3
zshrc
View File

@ -75,6 +75,9 @@ alias pk="pkill -fc"
alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc" alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc"
alias sc="systemctl" alias sc="systemctl"
alias sysc="systemctl" alias sysc="systemctl"
alias wg="sudo wg"
alias wgdown="sudo wgdown"
alias wgup="sudo wgup"
alias zzz="sudo systemctl hibernate" alias zzz="sudo systemctl hibernate"
# recursive grep with line numbers and colour, ignoring binary files: # recursive grep with line numbers and colour, ignoring binary files: