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
@ -53,17 +53,28 @@ Supported distros are Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora.
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if [[ "$os" == "debian" && "$os_version" -lt 9 ]]; then
|
function check_os_version {
|
||||||
echo "Debian 9 or higher is required to use this installer.
|
local required_version=$1
|
||||||
This version of Debian is too old and unsupported."
|
if [[ "$os_version" -lt "$required_version" ]]; then
|
||||||
exit
|
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
|
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
|
# Detect environments where $PATH does not include the sbin directories
|
||||||
if ! grep -q sbin <<< "$PATH"; then
|
if ! grep -q sbin <<< "$PATH"; then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user