1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-06-05 13:00:48 +00:00

Add validation for $SERVER_PUB_NIC

This commit is contained in:
randomshell 2020-07-02 10:56:37 +00:00
parent 23e31150f9
commit 45f533cbdd

View File

@ -63,8 +63,10 @@ function installWireGuard() {
read -rp "IPv4 or IPv6 public address: " -e -i "$SERVER_PUB_IP" SERVER_PUB_IP
# Detect public interface and pre-fill for the user
SERVER_PUB_NIC="$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)"
read -rp "Public interface: " -e -i "$SERVER_PUB_NIC" SERVER_PUB_NIC
SERVER_NIC="$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)"
until [[ "$SERVER_PUB_NIC" =~ ^[a-zA-Z0-9_]+$ ]]; do
read -rp "Public interface: " -e -i "$SERVER_NIC" SERVER_PUB_NIC
done
until [[ "$SERVER_WG_NIC" =~ ^[a-zA-Z0-9_]+$ ]]; do
read -rp "WireGuard interface name: " -e -i wg0 SERVER_WG_NIC