SOLR-9475: Imrpove distro detection by grepping /etc/os-release and adding lsb_release -i

This commit is contained in:
Jan Høydahl 2016-10-04 09:22:07 +02:00
parent 3a76ef1193
commit 2ad00826a3
1 changed files with 27 additions and 25 deletions

View File

@ -59,31 +59,33 @@ print_error() {
exit 1 exit 1
} }
proc_version=`cat /etc/*-release 2>/dev/null` # Locate *NIX distribution by looking for match from various detection strategies
if [[ $? -gt 0 ]]; then # We start with /etc/os-release, as this will also work for Docker containers
if [ -f "/proc/version" ]; then for command in "grep -E \"^NAME=\" /etc/os-release" \
proc_version=`cat /proc/version` "lsb_release -i" \
else "cat /proc/version" \
proc_version=`uname -a` "uname -a" ; do
fi distro_string=$(eval $command 2>/dev/null)
fi unset distro
if [[ ${distro_string,,} == *"debian"* ]]; then
if [[ $proc_version == *"Debian"* ]]; then distro=Debian
distro=Debian elif [[ ${distro_string,,} == *"red hat"* ]]; then
elif [[ $proc_version == *"Red Hat"* ]]; then distro=RedHat
distro=RedHat elif [[ ${distro_string,,} == *"centos"* ]]; then
elif [[ $proc_version == *"CentOS"* ]]; then distro=CentOS
distro=CentOS elif [[ ${distro_string,,} == *"ubuntu"* ]]; then
elif [[ $proc_version == *"Ubuntu"* ]]; then distro=Ubuntu
distro=Ubuntu elif [[ ${distro_string,,} == *"suse"* ]]; then
elif [[ $proc_version == *"SUSE"* ]]; then distro=SUSE
distro=SUSE elif [[ ${distro_string,,} == *"darwin"* ]]; then
elif [[ $proc_version == *"Darwin"* ]]; then echo "Sorry, this script does not support macOS. You'll need to setup Solr as a service manually using the documentation provided in the Solr Reference Guide."
echo "Sorry, this script does not support macOS. You'll need to setup Solr as a service manually using the documentation provided in the Solr Reference Guide." echo "You could also try installing via Homebrew (http://brew.sh/), e.g. brew install solr"
echo "You could also try installing via Homebrew (http://brew.sh/), e.g. brew install solr" exit 1
exit 1 fi
else if [[ $distro ]] ; then break ; fi
echo -e "\nERROR: Your Linux distribution ($proc_version) not supported by this script!\nYou'll need to setup Solr as a service manually using the documentation provided in the Solr Reference Guide.\n" 1>&2 done
if [[ ! $distro ]] ; then
echo -e "\nERROR: Unable to auto-detect your *NIX distribution!\nYou'll need to setup Solr as a service manually using the documentation provided in the Solr Reference Guide.\n" 1>&2
exit 1 exit 1
fi fi