Changed the check for Red Hat forks

Instead of checking for the new CentOS forks IDs, the check is made on the file "redhat-release".

This should include any future fork without the need to update this script.

I kept the check in the "get_distribution()" function, but let me know if it would make sense to have a  "check_forked_redhat()" function instead, in order to stay aligned with the current script logic.
This commit is contained in:
Nuno do Carmo 2021-05-01 18:15:35 +02:00 committed by GitHub
parent e37ddadc3f
commit d471636480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -121,12 +121,13 @@ get_distribution() {
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Updates the "lsb_dist" variable for the CentOS forks
# new IDs will be updated in the future.
case "$lsb_dist" in
almalinux)
# by checking the file "redhat-release" present in the Red Hat based distros.
if [ -r /etc/redhat-release ]; then
if ! egrep -i "centos|redhat|red hat|fedora" /etc/redhat-release; then
echo "Forked distribution, switching to CentOS ID"
lsb_dist="centos"
;;
esac
fi
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"