-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#114 Cache Solr downloads when running GitHub workflows
- Loading branch information
Showing
3 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Script to download Solr. By default, version 9.4.0 will be downloaded. | ||
# Another Solr version can be specified using the `--version` option. | ||
|
||
# Define variables and their default values | ||
version="9.4.0" | ||
|
||
# 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 | ||
# Create variable name from option name | ||
v="${1/--/}" # uses parameter expansion removing '--' | ||
|
||
# Read option value into variable | ||
declare "$v"="$2" | ||
|
||
# Process next option | ||
shift | ||
fi | ||
fi | ||
shift | ||
done | ||
|
||
# Check --version input | ||
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Unrecognized version number: $version" | ||
echo "The --version option requires a 3-digit version number, e.g.: 9.4.0" | ||
exit 1 | ||
fi | ||
|
||
SOLR_VERSION="$version" | ||
SOLR_TAR="solr-$SOLR_VERSION.tgz" | ||
|
||
# Define Solr download URL (which differs for versions >=9.0.0) | ||
if [[ "$version" =~ ^[1-8]\.[0-9]+\.[0-9]+$ ]]; then | ||
SOLR_URL="https://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/$SOLR_TAR" | ||
elif [[ "$version" =~ ^(9|[1-9][0-9]+)\.[0-9]+\.[0-9]+$ ]]; then | ||
SOLR_URL="https://www.apache.org/dyn/closer.lua/solr/solr/$SOLR_VERSION/$SOLR_TAR?action=download" | ||
fi | ||
|
||
# Download Solr version | ||
echo "Getting: $SOLR_URL" | ||
wget -q --show-progress --progress=bar:force $SOLR_URL -O $SOLR_TAR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters