dotfiles/.local/bin/scripts/vpn
Arthur Khachaturov 775a43810c
script changes
2024-08-18 03:41:19 +03:00

41 lines
720 B
Bash
Executable file

#!/bin/bash
IFNAME="wg_lva"
while [ "$#" -gt 0 ]; do
case "$1" in
'd'|'-d'|'--dpi') DPI="_d"
;;
'm'|'msk') IFNAME='wg_msk'
;;
'-v'|'--verbose') VERBOSE=1
;;
*) echo "Wrong argument!"; exit 1
;;
esac
shift
done
if [ -z "${VERBOSE}" ]; then
exec &>/dev/null
else
set -x
fi
UP_NAME="$(ip link show | grep 'wg' | cut -d ' ' -f 2 | sed 's/://')"
IFNAME="${IFNAME}${DPI}"
if [ -n "${UP_NAME}" ]; then
if [ "${UP_NAME}" != "${IFNAME}" ]; then
wg-quick down "${UP_NAME}"
wg-quick up "${IFNAME}"
else
wg-quick down "${UP_NAME}"
fi
else
wg-quick up "${IFNAME}"
fi
pkill -36 dwmblocks
# vim: ft=bash