From d30e11d019c80648b17d7f76eb81aba4ea8f742a Mon Sep 17 00:00:00 2001 From: Nyr Date: Thu, 14 May 2020 19:05:05 +0200 Subject: [PATCH] Improve TUN device check While it looks hackish, I don't think there's a better way (in Bash) to open the /dev/net/tun character device. Checking for presence of /dev/net/tun like were doing is not good enough. --- openvpn-install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index bab1d8d..c87a88d 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -57,9 +57,11 @@ This version of CentOS is too old and unsupported" exit fi -if [[ ! -e /dev/net/tun ]]; then - echo "The TUN device is not available -You need to enable TUN before running this script" +if [[ -e /dev/net/tun ]] && exec 2>/dev/null 7<>/dev/net/tun; then + exec 7>&- +else + echo "This system does not have the TUN device available +TUN needs to be enabled before running this installer" exit fi