lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jan...@apache.org
Subject lucene-solr:master: SOLR-9475: Imrpove distro detection by grepping /etc/os-release and adding lsb_release -i
Date Tue, 04 Oct 2016 07:25:19 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 3a76ef119 -> 2ad00826a


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2ad00826
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2ad00826
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2ad00826

Branch: refs/heads/master
Commit: 2ad00826a3db17410a1bf70b4149d584fc4ddd02
Parents: 3a76ef1
Author: Jan Høydahl <janhoy@apache.org>
Authored: Tue Oct 4 09:22:07 2016 +0200
Committer: Jan Høydahl <janhoy@apache.org>
Committed: Tue Oct 4 09:22:07 2016 +0200

----------------------------------------------------------------------
 solr/bin/install_solr_service.sh | 52 ++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ad00826/solr/bin/install_solr_service.sh
----------------------------------------------------------------------
diff --git a/solr/bin/install_solr_service.sh b/solr/bin/install_solr_service.sh
index 73c0712..6b9df79 100755
--- a/solr/bin/install_solr_service.sh
+++ b/solr/bin/install_solr_service.sh
@@ -59,31 +59,33 @@ print_error() {
   exit 1
 }
 
-proc_version=`cat /etc/*-release 2>/dev/null`
-if [[ $? -gt 0 ]]; then
-  if [ -f "/proc/version" ]; then
-    proc_version=`cat /proc/version`
-  else
-    proc_version=`uname -a`
-  fi
-fi
-
-if [[ $proc_version == *"Debian"* ]]; then
-  distro=Debian
-elif [[ $proc_version == *"Red Hat"* ]]; then
-  distro=RedHat
-elif [[ $proc_version == *"CentOS"* ]]; then
-  distro=CentOS
-elif [[ $proc_version == *"Ubuntu"* ]]; then
-  distro=Ubuntu
-elif [[ $proc_version == *"SUSE"* ]]; then
-  distro=SUSE
-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 "You could also try installing via Homebrew (http://brew.sh/), e.g. brew install solr"
-  exit 1
-else
-  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
+# Locate *NIX distribution by looking for match from various detection strategies
+# We start with /etc/os-release, as this will also work for Docker containers
+for command in "grep -E \"^NAME=\" /etc/os-release" \
+               "lsb_release -i" \
+               "cat /proc/version" \
+               "uname -a" ; do
+    distro_string=$(eval $command 2>/dev/null)
+    unset distro
+    if [[ ${distro_string,,} == *"debian"* ]]; then
+      distro=Debian
+    elif [[ ${distro_string,,} == *"red hat"* ]]; then
+      distro=RedHat
+    elif [[ ${distro_string,,} == *"centos"* ]]; then
+      distro=CentOS
+    elif [[ ${distro_string,,} == *"ubuntu"* ]]; then
+      distro=Ubuntu
+    elif [[ ${distro_string,,} == *"suse"* ]]; then
+      distro=SUSE
+    elif [[ ${distro_string,,} == *"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 "You could also try installing via Homebrew (http://brew.sh/), e.g. brew install
solr"
+      exit 1
+    fi
+    if [[ $distro ]] ; then break ; fi
+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
 fi
 


Mime
View raw message