SOLR-9508: Install script should check existence of tools, and add option to NOT start service

This commit is contained in:
Jan Høydahl 2016-09-21 21:49:12 +02:00
parent 15cee3141c
commit b894ab292d
2 changed files with 36 additions and 4 deletions

View File

@ -149,6 +149,9 @@ Other Changes
* SOLR-9538: Relocate (BinaryResponse|JSON|Smile)Writer tests to org.apache.solr.response
which is the package of the classes they test. (Jonny Marks via Christine Poerschke)
* SOLR-9508: Install script install_solr_service.sh now checks existence of tools.
New option -n to avoid starting service after installation (janhoy)
================== 6.2.1 ==================
Bug Fixes

37
solr/bin/install_solr_service.sh Normal file → Executable file
View File

@ -27,7 +27,7 @@ print_usage() {
fi
echo ""
echo "Usage: install_solr_service.sh path_to_solr_distribution_archive OPTIONS"
echo "Usage: install_solr_service.sh <path_to_solr_distribution_archive> [OPTIONS]"
echo ""
echo " The first argument to the script must be a path to a Solr distribution archive, such as solr-5.0.0.tgz"
echo " (only .tgz or .zip are supported formats for the archive)"
@ -48,10 +48,17 @@ print_usage() {
echo ""
echo " -f Upgrade Solr. Overwrite symlink and init script of previous installation."
echo ""
echo " -n Do not start Solr service after install, and do not abort on missing Java"
echo ""
echo " NOTE: Must be run as the root user"
echo ""
} # end print_usage
print_error() {
echo $1
exit 1
}
proc_version=`cat /etc/*-release 2>/dev/null`
if [[ $? -gt 0 ]]; then
if [ -f "/proc/version" ]; then
@ -104,6 +111,7 @@ else
exit 1
fi
SOLR_START=true
if [ $# -gt 1 ]; then
shift
while true; do
@ -152,6 +160,10 @@ if [ $# -gt 1 ]; then
SOLR_UPGRADE="YES"
shift 1
;;
-n)
SOLR_START=false
shift 1
;;
-help|-usage)
print_usage ""
exit 0
@ -172,6 +184,19 @@ if [ $# -gt 1 ]; then
done
fi
# Test for availability of needed tools
if [[ $is_tar ]] ; then
tar --version &>/dev/null || print_error "Script requires the 'tar' command"
else
unzip -hh &>/dev/null || print_error "Script requires the 'unzip' command"
fi
if [[ $SOLR_START == "true" ]] ; then
service --version &>/dev/null || print_error "Script requires the 'service' command"
java -version &>/dev/null || print_error "Solr requires java, please install or set JAVA_HOME properly"
fi
lsof -h &>/dev/null || echo "We recommend installing the 'lsof' command for more stable start/stop of Solr"
if [ -z "$SOLR_EXTRACT_DIR" ]; then
SOLR_EXTRACT_DIR=/opt
fi
@ -334,6 +359,10 @@ 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
if [[ $SOLR_START == "true" ]] ; then
service "$SOLR_SERVICE" start
sleep 5
service "$SOLR_SERVICE" status
else
echo "Not starting Solr service (option -n given). Start manually with 'service $SOLR_SERVICE start'"
fi