fix env variables
This commit is contained in:
parent
6a386f97e0
commit
0bc4e5f6f3
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# bash-refine v1.3.0: bash-refine.sh, Felix Lohmeier, 2020-07-31
|
||||
# bash-refine v1.3.1: bash-refine.sh, Felix Lohmeier, 2020-07-31
|
||||
# https://gist.github.com/felixlohmeier/d76bd27fbc4b8ab6d683822cdf61f81d
|
||||
# license: MIT License https://choosealicense.com/licenses/mit/
|
||||
|
||||
|
@ -8,21 +8,29 @@
|
|||
# ================================== CONFIG ================================== #
|
||||
|
||||
endpoint="${REFINE_ENDPOINT:-http://localhost:3333}"
|
||||
memory="${REFINE_MEMORY:-1400M}" # increase to available RAM
|
||||
memory="${REFINE_MEMORY:-1400M}"
|
||||
csrf="${REFINE_CSRF:-true}"
|
||||
date="$(date +%Y%m%d_%H%M%S)"
|
||||
if [[ -z "${REFINE_WORKDIR}" ]]; then
|
||||
workdir="output/${date}"
|
||||
if [[ -n "$(readlink -e "${REFINE_WORKDIR}")" ]]; then
|
||||
workdir="$(readlink -e "${REFINE_WORKDIR}")"
|
||||
else
|
||||
workdir="${REFINE_WORKDIR}"
|
||||
workdir="$(readlink -m "${BASH_SOURCE%/*}/output/${date}")"
|
||||
fi
|
||||
if [[ -z "${REFINE_LOGFILE}" ]]; then
|
||||
logfile="log/${date}.log"
|
||||
if [[ -n "$(readlink -e "${REFINE_LOGFILE}")" ]]; then
|
||||
logfile="$(readlink -e "${REFINE_LOGFILE}")"
|
||||
else
|
||||
logfile="${REFINE_LOGFILE}"
|
||||
logfile="$(readlink -m "${BASH_SOURCE%/*}/log/${date}.log")"
|
||||
fi
|
||||
if [[ -n "$(readlink -e "${REFINE_JQ}")" ]]; then
|
||||
jq="$(readlink -e "${REFINE_JQ}")"
|
||||
else
|
||||
jq="$(readlink -m "${BASH_SOURCE%/*}/lib/jq")"
|
||||
fi
|
||||
if [[ -n "$(readlink -e "${REFINE_REFINE}")" ]]; then
|
||||
refine="$(readlink -e "${REFINE_REFINE}")"
|
||||
else
|
||||
refine="$(readlink -m "${BASH_SOURCE%/*}/lib/openrefine/refine")"
|
||||
fi
|
||||
csrf="${REFINE_CSRF:-true}" # set to false for OpenRefine < 3.3
|
||||
jq="${REFINE_JQ:-jq}" # path to executable
|
||||
refine="${REFINE_REFINE:-openrefine/refine}" # path to executable
|
||||
|
||||
declare -A checkpoints # associative array for stats
|
||||
declare -A pids # associative array for monitoring background jobs
|
||||
|
@ -45,6 +53,7 @@ function requirements {
|
|||
# download jq and OpenRefine if necessary
|
||||
if [[ -z "$(readlink -e "${jq}")" ]]; then
|
||||
echo "Download jq..."
|
||||
mkdir -p "$(dirname "${jq}")"
|
||||
# jq 1.4 has much faster startup time than 1.5 and 1.6
|
||||
curl -L --output "${jq}" \
|
||||
"https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64"
|
||||
|
@ -76,7 +85,7 @@ function requirements {
|
|||
function refine_start {
|
||||
echo "start OpenRefine server..."
|
||||
local dir
|
||||
dir="$(readlink -f "${workdir}")"
|
||||
dir="$(readlink -e "${workdir}")"
|
||||
${refine} -v warn -m "${memory}" -p "${endpoint##*:}" -d "${dir}" &
|
||||
pid_server=${!}
|
||||
timeout 30s bash -c "until curl -s \"${endpoint}\" \
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/bin/bash
|
||||
# bash-refine v1.3.0: minimal.sh, Felix Lohmeier, 2020-07-31
|
||||
# bash-refine v1.3.1: minimal.sh, Felix Lohmeier, 2020-07-31
|
||||
# https://gist.github.com/felixlohmeier/d76bd27fbc4b8ab6d683822cdf61f81d
|
||||
# license: MIT License https://choosealicense.com/licenses/mit/
|
||||
|
||||
# =============================== ENVIRONMENT ================================ #
|
||||
|
||||
source "${BASH_SOURCE%/*}/bash-refine.sh" || exit 1
|
||||
cd "${BASH_SOURCE%/*}/" || exit 1
|
||||
source bash-refine.sh
|
||||
init
|
||||
|
||||
# ================================= STARTUP ================================== #
|
||||
|
|
18
templates.sh
18
templates.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# bash-refine v1.3.0: templates.sh, Felix Lohmeier, 2020-07-31
|
||||
# bash-refine v1.3.1: templates.sh, Felix Lohmeier, 2020-07-31
|
||||
# https://gist.github.com/felixlohmeier/d76bd27fbc4b8ab6d683822cdf61f81d
|
||||
# license: MIT License https://choosealicense.com/licenses/mit/
|
||||
|
||||
|
@ -13,21 +13,21 @@
|
|||
|
||||
# =============================== ENVIRONMENT ================================ #
|
||||
|
||||
# source the main script
|
||||
source "${BASH_SOURCE%/*}/bash-refine.sh" || exit 1
|
||||
|
||||
# make script executable from another directory
|
||||
cd "${BASH_SOURCE%/*}/" || exit 1
|
||||
|
||||
# source the main script
|
||||
source bash-refine.sh
|
||||
|
||||
### override default config?
|
||||
#endpoint="http://localhost:3333"
|
||||
#memory="1400M" # increase to available RAM
|
||||
#date="$(date +%Y%m%d_%H%M%S)"
|
||||
#workdir="output/${date}"
|
||||
#logfile="log/${date}.log"
|
||||
#csrf=true # set to false for OpenRefine < 3.3
|
||||
#jq="jq" # path to executable
|
||||
#refine="openrefine/refine" # path to executable
|
||||
#date="$(date +%Y%m%d_%H%M%S)"
|
||||
#workdir="${BASH_SOURCE%/*}/output/${date}"
|
||||
#logfile="${BASH_SOURCE%/*}/log/${date}.log"
|
||||
#jq="${BASH_SOURCE%/*}/lib/jq" # path to executable
|
||||
#refine="${BASH_SOURCE%/*}/lib/openrefine/refine" # path to executable
|
||||
|
||||
# check requirements, set trap, create workdir and tee to logfile
|
||||
init
|
||||
|
|
Loading…
Reference in New Issue