Apache Lucene open-source search software
Add install script support for CentOS and better distro detection under Docker
Jan Høydahla1bbc996e4e6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 4531a5d9031..aca42aab0fb 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -139,6 +139,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----------------------diff --git a/solr/bin/install_solr_service.sh b/solr/bin/install_solr_service.shindex c91777ab7d8..3a8fb88bcab 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`+ fifiif [[ $proc_version == *"Debian"* ]]; thendistro=Debianelif [[ $proc_version == *"Red Hat"* ]]; thendistro=RedHat+elif [[ $proc_version == *"CentOS"* ]]; then+ distro=CentOSelif [[ $proc_version == *"Ubuntu"* ]]; thendistro=Ubuntuelif [[ $proc_version == *"SUSE"* ]]; thendistro=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 1elseecho -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>&2exit 1@@ -214,7 +223,7 @@ fisolr_uid="`id -u "$SOLR_USER"`"if [ $? -ne 0 ]; thenecho "Creating new user: $SOLR_USER"- if [ "$distro" == "RedHat" ]; then+ if [ "$distro" == "RedHat" ] || [ "$distro" == "CentOS" ] ; thenadduser "$SOLR_USER"elif [ "$distro" == "SUSE" ]; thenuseradd -m "$SOLR_USER"@@ -316,15 +325,15 @@ find "$SOLR_VAR_DIR" -type d -print0 | xargs -0 chmod 0750find "$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" ]]; thenchkconfig "$SOLR_SERVICE" onelseupdate-rc.d "$SOLR_SERVICE" defaultsfi+echo "Service $SOLR_SERVICE installed."+echo "Customize Solr startup configuration in /etc/default/$SOLR_SERVICE.in.sh"# start serviceservice "$SOLR_SERVICE" startsleep 5service "$SOLR_SERVICE" status--echo "Service $SOLR_SERVICE installed."