From 14d72d7b22bd2aed7b369d56a6e58a7d11989a2e Mon Sep 17 00:00:00 2001 From: angristan Date: Sun, 5 May 2019 17:47:14 +0200 Subject: [PATCH] Abort the script if OpenVZ or LXC Fix #8 --- wireguard-install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wireguard-install.sh b/wireguard-install.sh index 76ed6d5..598f422 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -5,6 +5,20 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi +if [ "$(systemd-detect-virt)" == "openvz" ]; then + echo "OpenVZ is not supported" + exit +fi + +if [ "$(systemd-detect-virt)" == "lxc" ]; then + echo "LXC is not supported (yet)." + echo "WireGuard can techniaclly run in an LXC container," + echo "but the kernel module has to be installed on the host," + echo "the container has to be run with some specific parameters" + echo "and only the tools need to be installed in the container." + exit +fi + # Detect public IPv4 address and pre-fill for the user SERVER_PUB_IPV4=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) read -rp "IPv4 or IPv6 public address: " -e -i "$SERVER_PUB_IPV4" SERVER_PUB_IP