Skip to content

Commit

Permalink
#1108 Removes again the --help option from install_solr_docker.sh as …
Browse files Browse the repository at this point in the history
…this is not a user-facing script but just used as part of automatic testing
  • Loading branch information
extracts committed Oct 10, 2023
1 parent 87370f4 commit a74167d
Showing 1 changed file with 8 additions and 40 deletions.
48 changes: 8 additions & 40 deletions bin/install_solr_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,7 @@ script_name="$(basename "$0")"
# Define variables and their default values
version="9.3.0"

# Define colors
DEFAULT='\033[0;33m' # Purple color for default values
OPTION='\033[1;32m' # Green
NC='\033[0m' # No Color

# Print command line help to stderr
displayHelp() {
echo "Usage: $script_name [OPTIONS]" >&2
echo
echo -e "This script will install Solr version 9.3.0, unless"
echo -e "option ${OPTION}--version${NC} is specified with another Solr version."
echo
echo "Options:"
echo
echo -e " ${OPTION}--help${NC} (${OPTION}-h${NC}) Print out help"
echo
echo -e " DEFAULT"
echo -e " ${OPTION}--version${NC} Solr version (${DEFAULT}$version${NC})"
echo
echo "Examples:"
echo
echo -e " $script_name"
echo -e " $script_name ${OPTION}--help${NC}"
echo -e " $script_name ${OPTION}--version${NC} ${DEFAULT}7.7.2${NC}"
echo
exit 1
}

# Display command line help if '-h' or '--help' is given as first option
if [ $# -gt 0 ]; then
if [[ $1 == "-h" || $1 == "--help" ]]; then
displayHelp
exit 0
fi
fi

# Parse any other command line options
# Parse command line options
while [ $# -gt 0 ]; do
if [[ $1 == "--"* ]]; then # only deal with long options
if [[ -n "$2" && $2 != "-"* ]]; then # ignore options without a value
Expand All @@ -62,18 +26,22 @@ while [ $# -gt 0 ]; do
shift
done

# Download Solr version
if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then
SOLR_VERSION="$version"
ant download-solr -DsolrVersion=$SOLR_VERSION -DdownloadDir=./downloads
elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then
elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then # new archive URL for versions >9.0.0
SOLR_VERSION="$version"
wget -q "https://archive.apache.org/dist/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz" -O - | tar -xz
SOLR_URL="https://archive.apache.org/dist/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz"
echo "Getting: $SOLR_URL"
wget -q $SOLR_URL -O - | tar -xz
else
echo "Unrecognized version number"
echo -e "The ${OPTION}--version${NC} option requires a 3-digit version number, e.g.: 9.3.0"
echo -e "The --version option requires a 3-digit version number, e.g.: 9.3.0"
exit 1
fi

# Configure & start Solr
cd solr-$SOLR_VERSION
./bin/solr start -force
./bin/solr create -c opus4 -force
Expand Down

0 comments on commit a74167d

Please sign in to comment.