Update openvpn-install.sh

Add Oracle Linux support
This commit is contained in:
George Lazarev 2021-07-12 11:18:31 +03:00 committed by GitHub
parent 4f737ac2f8
commit 7b09018d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,10 @@ elif [[ -e /etc/debian_version ]]; then
os="debian" os="debian"
os_version=$(grep -oE '[0-9]+' /etc/debian_version | head -1) os_version=$(grep -oE '[0-9]+' /etc/debian_version | head -1)
group_name="nogroup" group_name="nogroup"
elif [[ -e /etc/system-release ]]; then
os="oracle"
os_version=$(grep -oE '[0-9]+' /etc/system-release | head -1)
group_name="nobody"
elif [[ -e /etc/centos-release ]]; then elif [[ -e /etc/centos-release ]]; then
os="centos" os="centos"
os_version=$(grep -oE '[0-9]+' /etc/centos-release | head -1) os_version=$(grep -oE '[0-9]+' /etc/centos-release | head -1)
@ -40,7 +44,7 @@ elif [[ -e /etc/fedora-release ]]; then
group_name="nobody" group_name="nobody"
else else
echo "This installer seems to be running on an unsupported distribution. echo "This installer seems to be running on an unsupported distribution.
Supported distributions are Ubuntu, Debian, CentOS, and Fedora." Supported distributions are Ubuntu, Debian, CentOS, Oracle Linux and Fedora."
exit exit
fi fi
@ -62,6 +66,12 @@ This version of CentOS is too old and unsupported."
exit exit
fi fi
if [[ "$os" == "oracle" && "$os_version" -lt 7 ]]; then
echo "Oracle Linux 7 or higher is required to use this installer.
This version of Oracle Linux is too old and unsupported."
exit
fi
# Detect environments where $PATH does not include the sbin directories # Detect environments where $PATH does not include the sbin directories
if ! grep -q sbin <<< "$PATH"; then if ! grep -q sbin <<< "$PATH"; then
echo '$PATH does not include sbin. Try using "su -" instead of "su".' echo '$PATH does not include sbin. Try using "su -" instead of "su".'
@ -197,7 +207,7 @@ if [[ ! -e /etc/openvpn/server/server.conf ]]; then
echo "OpenVPN installation is ready to begin." echo "OpenVPN installation is ready to begin."
# Install a firewall in the rare case where one is not already available # Install a firewall in the rare case where one is not already available
if ! systemctl is-active --quiet firewalld.service && ! hash iptables 2>/dev/null; then if ! systemctl is-active --quiet firewalld.service && ! hash iptables 2>/dev/null; then
if [[ "$os" == "centos" || "$os" == "fedora" ]]; then if [[ "$os" == "centos" || "$os" == "fedora" || "$os" == "oracle" ]]; then
firewall="firewalld" firewall="firewalld"
# We don't want to silently enable firewalld, so we give a subtle warning # We don't want to silently enable firewalld, so we give a subtle warning
# If the user continues, firewalld will be installed and enabled during setup # If the user continues, firewalld will be installed and enabled during setup
@ -220,6 +230,9 @@ LimitNPROC=infinity" > /etc/systemd/system/openvpn-server@server.service.d/disab
elif [[ "$os" = "centos" ]]; then elif [[ "$os" = "centos" ]]; then
yum install -y epel-release yum install -y epel-release
yum install -y openvpn openssl ca-certificates tar $firewall yum install -y openvpn openssl ca-certificates tar $firewall
elif [[ "$os" = "oracle" ]]; then
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install -y openvpn openssl ca-certificates tar $firewall
else else
# Else, OS must be Fedora # Else, OS must be Fedora
dnf install -y openvpn openssl ca-certificates tar $firewall dnf install -y openvpn openssl ca-certificates tar $firewall
@ -541,7 +554,7 @@ else
if [[ "$os" = "debian" || "$os" = "ubuntu" ]]; then if [[ "$os" = "debian" || "$os" = "ubuntu" ]]; then
apt-get remove --purge -y openvpn apt-get remove --purge -y openvpn
else else
# Else, OS must be CentOS or Fedora # Else, OS must be CentOS, Oracle Linux or Fedora
yum remove -y openvpn yum remove -y openvpn
fi fi
echo echo