diff --git a/script/wgdown b/script/wgdown new file mode 100755 index 0000000..4fe4f66 --- /dev/null +++ b/script/wgdown @@ -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 diff --git a/script/wgup b/script/wgup new file mode 100755 index 0000000..6fef1f8 --- /dev/null +++ b/script/wgup @@ -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" diff --git a/zshrc b/zshrc index 32e1c6d..7620d34 100644 --- a/zshrc +++ b/zshrc @@ -75,6 +75,9 @@ alias pk="pkill -fc" alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc" alias sc="systemctl" alias sysc="systemctl" +alias wg="sudo wg" +alias wgdown="sudo wgdown" +alias wgup="sudo wgup" alias zzz="sudo systemctl hibernate" # recursive grep with line numbers and colour, ignoring binary files: