[WIP] Added wireguard, prepare to test and debug

This commit is contained in:
Alex Kh 2021-11-30 16:56:24 +04:00
parent e644575bc5
commit 7c7f77adc6
98 changed files with 4410 additions and 302 deletions

51
client/scripts/commons.sh Normal file
View file

@ -0,0 +1,51 @@
#!/bin/bash
printv() {
if [ -t 1 ]; then
NCOLORS=$(tput colors)
if test -n "$NCOLORS" && test "$NCOLORS" -ge 8; then
NORMAL="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
fi
fi
if [[ $2 = 'G' ]]; then
# shellcheck disable=SC2086
echo $1 -e "${GREEN}$3${NORMAL}"
elif [[ $2 = 'Y' ]]; then
# shellcheck disable=SC2086
echo $1 -e "${YELLOW}$3${NORMAL}"
elif [[ $2 = 'N' ]]; then
# shellcheck disable=SC2086
echo $1 -e "$3"
else
# shellcheck disable=SC2086
echo $1 -e "${RED}$3${NORMAL}"
fi
}
print() {
printv '' "$1" "$2"
}
printn() {
printv "-n" "$1" "$2"
}
error() {
printv '' R "$1"
}
die() {
if [[ "$1" ]]; then
error "$1"
else
error Failed
fi
exit 1
}