From 94c94bbbc9cd650bbe74e806ca02ec7399a5369a Mon Sep 17 00:00:00 2001 From: Nyr Date: Fri, 3 Sep 2021 18:58:25 +0200 Subject: [PATCH] Add support for AlmaLinux and Rocky Linux An unrelated fix to avoid one harmless warning during removal is also included. --- README.md | 2 +- openvpn-install.sh | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 521d4c0..e4f84ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ **New: [wireguard-install](https://github.com/Nyr/wireguard-install) is also available.** ## openvpn-install -OpenVPN [road warrior](http://en.wikipedia.org/wiki/Road_warrior_%28computing%29) installer for Ubuntu, Debian, CentOS and Fedora. +OpenVPN [road warrior](http://en.wikipedia.org/wiki/Road_warrior_%28computing%29) installer for Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora. This script will let you set up your own VPN server in no more than a minute, even if you haven't used OpenVPN before. It has been designed to be as unobtrusive and universal as possible. diff --git a/openvpn-install.sh b/openvpn-install.sh index d2255d5..b39e795 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -30,9 +30,9 @@ elif [[ -e /etc/debian_version ]]; then os="debian" os_version=$(grep -oE '[0-9]+' /etc/debian_version | head -1) group_name="nogroup" -elif [[ -e /etc/centos-release ]]; then +elif [[ -e /etc/almalinux-release || -e /etc/rocky-release || -e /etc/centos-release ]]; then os="centos" - os_version=$(grep -oE '[0-9]+' /etc/centos-release | head -1) + os_version=$(grep -shoE '[0-9]+' /etc/almalinux-release /etc/rocky-release /etc/centos-release | head -1) group_name="nobody" elif [[ -e /etc/fedora-release ]]; then os="fedora" @@ -40,7 +40,7 @@ elif [[ -e /etc/fedora-release ]]; then group_name="nobody" else echo "This installer seems to be running on an unsupported distribution. -Supported distributions are Ubuntu, Debian, CentOS, and Fedora." +Supported distros are Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora." exit fi @@ -202,7 +202,7 @@ if [[ ! -e /etc/openvpn/server/server.conf ]]; then [[ -z "$client" ]] && client="client" echo echo "OpenVPN installation is ready to begin." - # Install a firewall in the rare case where one is not already available + # Install a firewall if firewalld or iptables are not already available if ! systemctl is-active --quiet firewalld.service && ! hash iptables 2>/dev/null; then if [[ "$os" == "centos" || "$os" == "fedora" ]]; then firewall="firewalld" @@ -542,14 +542,15 @@ else semanage port -d -t openvpn_port_t -p "$protocol" "$port" fi systemctl disable --now openvpn-server@server.service - rm -rf /etc/openvpn/server rm -f /etc/systemd/system/openvpn-server@server.service.d/disable-limitnproc.conf rm -f /etc/sysctl.d/99-openvpn-forward.conf if [[ "$os" = "debian" || "$os" = "ubuntu" ]]; then + rm -rf /etc/openvpn/server apt-get remove --purge -y openvpn else # Else, OS must be CentOS or Fedora yum remove -y openvpn + rm -rf /etc/openvpn/server fi echo echo "OpenVPN removed!"