mirror of
https://github.com/Nyr/openvpn-install.git
synced 2025-04-04 21:23:31 +03:00
Optimization:
Use a function + case statement to print the error message and exit when a required OS version is not met
This commit is contained in:
parent
bb2b750c9e
commit
55098fb853
1 changed files with 21 additions and 10 deletions
|
@ -53,17 +53,28 @@ Supported distros are Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora.
|
|||
esac
|
||||
|
||||
|
||||
if [[ "$os" == "debian" && "$os_version" -lt 9 ]]; then
|
||||
echo "Debian 9 or higher is required to use this installer.
|
||||
This version of Debian is too old and unsupported."
|
||||
exit
|
||||
fi
|
||||
function check_os_version {
|
||||
local required_version=$1
|
||||
if [[ "$os_version" -lt "$required_version" ]]; then
|
||||
echo "$os_name $required_version or higher is required to use this installer.
|
||||
This version of $os_name is too old and unsupported."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
case $os in
|
||||
ubuntu)
|
||||
check_os_version 1804
|
||||
;;
|
||||
debian)
|
||||
check_os_version 9
|
||||
;;
|
||||
centos)
|
||||
check_os_version 7
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
if [[ "$os" == "centos" && "$os_version" -lt 7 ]]; then
|
||||
echo "CentOS 7 or higher is required to use this installer.
|
||||
This version of CentOS is too old and unsupported."
|
||||
exit
|
||||
fi
|
||||
|
||||
# Detect environments where $PATH does not include the sbin directories
|
||||
if ! grep -q sbin <<< "$PATH"; then
|
||||
|
|
Loading…
Add table
Reference in a new issue