Skip to content

Commit

Permalink
Extend updateSchemaMDB.sh with option handling in addition to env vars.
Browse files Browse the repository at this point in the history
Relates to IQSS#6142.
  • Loading branch information
poikilotherm committed Sep 10, 2019
1 parent a5cb7e8 commit 17f03a4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions conf/solr/7.3.1/updateSchemaMDB.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e
set -euo pipefail

# This script updates the <field> and <copyField> schema configuration necessary to properly
# index custom metadata fields in Solr.
Expand All @@ -17,13 +17,37 @@ set -e
# coreutils: mktemp, csplit
# curl

### Init
usage() {
echo "usage: updateSchemaMDB.sh [options]"
echo "options:"
echo " -d <url> Dataverse URL, defaults to http://localhost:8080"
echo " -h Show this help text"
echo " -s <url> Solr URL, defaults to http://localhost:8983"
echo " -t <path> Directory where to write the XML files. Defaults to /tmp"
echo " -u <key/file> Dataverse unblock key either as key string or path to keyfile"
}

### Init (with sane defaults)
DATAVERSE_URL=${DATAVERSE_URL:-"http://localhost:8080"}
SOLR_URL=${SOLR_URL:-"http://localhost:8983"}
TARGET=${TARGET:-"/tmp"}
UNBLOCK_KEY=${UNBLOCK_KEY:-""}

# if cmdline args are given, override any env var setting (or defaults)
while getopts ":d:hs:t:u:" opt
do
case $opt in
d) DATAVERSE_URL=${OPTARG};;
h) usage; exit 0;;
s) SOLR_URL=${OPTARG};;
t) TARGET=${OPTARG};;
u) UNBLOCK_KEY=${OPTARG};;
:) echo "Missing option argument for -${OPTARG}. Use -h for help." >&2; exit 1;;
\?) echo "Unknown option -${OPTARG}." >&2; usage; exit 1;;
esac
done

# Special handling of unblock key depending on referencing a secret file or key in var
UNBLOCK_KEY=${UNBLOCK_KEY:-""}
if [ ! -z "${UNBLOCK_KEY}" ]; then
if [ -f "${UNBLOCK_KEY}" ]; then
UNBLOCK_KEY="?unblock-key=$(cat ${UNBLOCK_KEY})"
Expand Down

0 comments on commit 17f03a4

Please sign in to comment.