From 12ba1a9d9a40dfbf7bad91cfc600ff51b738107e Mon Sep 17 00:00:00 2001 From: Safa Bayar <43282745+rection@users.noreply.github.com> Date: Mon, 11 Nov 2019 01:18:34 -0500 Subject: [PATCH] Add Centos 8 Support (#506) --- README.md | 1 + openvpn-install.sh | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d80c28..a71f471 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ The script supports these OS and architectures: | -------------- | ---- | ----- | ----- | ----- | | Amazon Linux 2 | ❔ | ✅ | ❔ | ❔ | | Arch Linux | ❔ | ✅ | ❔ | ✅ | +| Centos 8 | ❌ | ✅ | ❔ | ❔ | | CentOS 7 | ❔ | ✅ | ❌ | ✅ | | Debian 8 | ✅ | ✅ | ❌ | ❌ | | Debian 9 | ❌ | ✅ | ✅ | ✅ | diff --git a/openvpn-install.sh b/openvpn-install.sh index 45615cd..61facdc 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -54,7 +54,7 @@ function checkOS () { source /etc/os-release if [[ "$ID" = "centos" ]]; then OS="centos" - if [[ ! $VERSION_ID == "7" ]]; then + if [[ ! $VERSION_ID =~ (7|8) ]]; then echo "⚠️ Your version of CentOS is not supported." echo "" echo "The script only support CentOS 7." @@ -621,7 +621,7 @@ function installOpenVPN () { apt-get install -y openvpn iptables openssl wget ca-certificates curl elif [[ "$OS" = 'centos' ]]; then yum install -y epel-release - yum install -y openvpn iptables openssl wget ca-certificates curl + yum install -y openvpn iptables openssl wget ca-certificates curl tar elif [[ "$OS" = 'amzn' ]]; then amazon-linux-extras install -y epel yum install -y openvpn iptables openssl wget ca-certificates curl @@ -668,12 +668,13 @@ function installOpenVPN () { SERVER_NAME="server_$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)" echo "set_var EASYRSA_REQ_CN $SERVER_CN" >> vars - # Workaround to remove unharmful error until easy-rsa 3.0.7 - # https://github.com/OpenVPN/easy-rsa/issues/261 - sed -i 's/^RANDFILE/#RANDFILE/g' pki/openssl-easyrsa.cnf - # Create the PKI, set up the CA, the DH params and the server certificate ./easyrsa init-pki + + # Workaround to remove unharmful error until easy-rsa 3.0.7 + # https://github.com/OpenVPN/easy-rsa/issues/261 + sed -i 's/^RANDFILE/#RANDFILE/g' pki/openssl-easyrsa.cnf + ./easyrsa --batch build-ca nopass if [[ $DH_TYPE == "2" ]]; then @@ -848,7 +849,7 @@ verb 3" >> /etc/openvpn/server.conf fi # Finally, restart and enable OpenVPN - if [[ "$OS" = 'arch' || "$OS" = 'fedora' ]]; then + if [[ "$OS" = 'arch' || "$OS" = 'fedora' || "$OS" = 'centos' ]]; then # Don't modify package-provided service cp /usr/lib/systemd/system/openvpn-server@.service /etc/systemd/system/openvpn-server@.service @@ -1144,7 +1145,7 @@ function removeOpenVPN () { PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2) # Stop OpenVPN - if [[ "$OS" =~ (fedora|arch) ]]; then + if [[ "$OS" =~ (fedora|arch|centos) ]]; then systemctl disable openvpn-server@server systemctl stop openvpn-server@server # Remove customised service