From 26a9c1fbc84d651e3451d086ab7131a4bb2249ed Mon Sep 17 00:00:00 2001 From: Teddysun Date: Mon, 31 Aug 2020 16:52:36 +0900 Subject: [PATCH] Update wireguard.sh --- wireguard.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/wireguard.sh b/wireguard.sh index 4826031..09dfd91 100644 --- a/wireguard.sh +++ b/wireguard.sh @@ -92,8 +92,7 @@ _nic() { _port() { local port="$(shuf -i 1024-20480 -n 1)" - while true - do + while true; do if _exists "netstat" && netstat -tunlp | grep -w "${port}" > /dev/null 2>&1; then port="$(shuf -i 1024-20480 -n 1)" else @@ -146,6 +145,7 @@ _is_installed() { if [ -s "/lib/modules/$(uname -r)/extra/wireguard.ko" ] \ || [ -s "/lib/modules/$(uname -r)/extra/wireguard.ko.xz" ] \ || [ -s "/lib/modules/$(uname -r)/updates/dkms/wireguard.ko" ] \ + || [ -s "/lib/modules/$(uname -r)/updates/dkms/wireguard.ko.xz" ] \ || [ -s "/lib/modules/$(uname -r)/kernel/drivers/net/wireguard/wireguard.ko" ] \ || [ -s "/lib/modules/$(uname -r)/kernel/drivers/net/wireguard/wireguard.ko.xz" ]; then install_flag[1]=1 @@ -193,10 +193,10 @@ check_os() { virt="$(systemd-detect-virt)" fi if [ -n "${virt}" -a "${virt}" = "lxc" ]; then - _error "Virtualization method is LXC, which is not supported." + _error "Virtualization is LXC, which is not supported." fi if [ -n "${virt}" -a "${virt}" = "openvz" ] || [ -d "/proc/vz" ]; then - _error "Virtualization method is OpenVZ, which is not supported." + _error "Virtualization is OpenVZ, which is not supported." fi [ -z "$(_os)" ] && _error "Not supported OS" case "$(_os)" in @@ -606,8 +606,7 @@ add_client() { default_client_if="/etc/wireguard/${SERVER_WG_NIC}_client" [ ! -s "${default_server_if}" ] && echo "The default server interface ($(_red ${default_server_if})) does not exists" && exit 1 [ ! -s "${default_client_if}" ] && echo "The default client interface ($(_red ${default_client_if})) does not exists" && exit 1 - while true - do + while true; do read -p "Please enter a client name (for example: wg1):" client if [ -z "${client}" ]; then _red "Client name can not be empty\n" @@ -711,8 +710,7 @@ remove_client() { fi default_server_if="/etc/wireguard/${SERVER_WG_NIC}.conf" [ ! -s "${default_server_if}" ] && echo "The default server interface ($(_red ${default_server_if})) does not exists" && exit 1 - while true - do + while true; do read -p "Please enter a client name you want to delete it (for example: wg1):" client if [ -z "${client}" ]; then _red "Client name can not be empty\n"