You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2016/09/20 09:35:20 UTC

lucene-solr:branch_6x: SOLR-9475: Add install script support for CentOS and better distro detection under Docker

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 09d399791 -> 74bf88f8f


SOLR-9475: Add install script support for CentOS and better distro detection under Docker

(cherry picked from commit a1bbc99)


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

Branch: refs/heads/branch_6x
Commit: 74bf88f8fe50b59e666f9387ca65ec26f821089d
Parents: 09d3997
Author: Jan H�ydahl <ja...@apache.org>
Authored: Tue Sep 20 11:22:53 2016 +0200
Committer: Jan H�ydahl <ja...@apache.org>
Committed: Tue Sep 20 11:34:57 2016 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt                 |  3 +++
 solr/bin/install_solr_service.sh | 25 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74bf88f8/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 91b89b7..b455232 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -109,6 +109,9 @@ Bug Fixes
 
 * SOLR-8080: bin/solr start script now exits with informative message if using wrong Java version (janhoy)
 
+* SOLR-9475: bin/install_solr_service.sh script got improved detection of Linux distro, especially within
+  virtualized/Docker environment through parsing of /etc/*-release files. Now also supports CentOS. (janhoy)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74bf88f8/solr/bin/install_solr_service.sh
----------------------------------------------------------------------
diff --git a/solr/bin/install_solr_service.sh b/solr/bin/install_solr_service.sh
index c91777a..3a8fb88 100644
--- a/solr/bin/install_solr_service.sh
+++ b/solr/bin/install_solr_service.sh
@@ -52,20 +52,29 @@ print_usage() {
   echo ""
 } # end print_usage
 
-if [ -f "/proc/version" ]; then
-  proc_version=`cat /proc/version`
-else
-  proc_version=`uname -a`
+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
   exit 1
@@ -214,7 +223,7 @@ fi
 solr_uid="`id -u "$SOLR_USER"`"
 if [ $? -ne 0 ]; then
   echo "Creating new user: $SOLR_USER"
-  if [ "$distro" == "RedHat" ]; then
+  if [ "$distro" == "RedHat" ] || [ "$distro" == "CentOS" ] ; then
     adduser "$SOLR_USER"
   elif [ "$distro" == "SUSE" ]; then
     useradd -m "$SOLR_USER"
@@ -316,15 +325,15 @@ find "$SOLR_VAR_DIR" -type d -print0 | xargs -0 chmod 0750
 find "$SOLR_VAR_DIR" -type f -print0 | xargs -0 chmod 0640
 
 # configure autostart of service
-if [[ "$distro" == "RedHat" || "$distro" == "SUSE" ]]; then
+if [[ "$distro" == "RedHat" || "$distro" == "CentOS" || "$distro" == "SUSE" ]]; then
   chkconfig "$SOLR_SERVICE" on
 else
   update-rc.d "$SOLR_SERVICE" defaults
 fi
+echo "Service $SOLR_SERVICE installed."
+echo "Customize Solr startup configuration in /etc/default/$SOLR_SERVICE.in.sh"
 
 # start service
 service "$SOLR_SERVICE" start
 sleep 5
 service "$SOLR_SERVICE" status
-
-echo "Service $SOLR_SERVICE installed."