frkn tool script for quick connection control

This commit is contained in:
Anthony Axenov 2024-08-26 16:22:03 +08:00
parent 4b1bd30170
commit 890f09b82b
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC

40
tools/frkn.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
function disconnect() {
echo "Отключаю $1"
sudo wg-quick down "$1"
echo
}
function connect() {
echo "Подключаю frkn-$1"
sudo wg-quick up "frkn-$1"
echo
}
country="$1"
countries=(uk ru nl nl2 ch)
current=$(sudo wg show | head -n 1 | awk '{print $2}')
if [ -z "$country" ]; then
IFS= read -rp "Выбери страну (${countries[*]}): " country
fi
case $country in
"down" )
if [ -n "$current" ]; then
disconnect "$current"
fi
;;
"status"|"show" )
sudo wg show
;;
* )
if [ -n "$current" ]; then
disconnect "$current"
fi
connect "$country"
;;
esac