-
Notifications
You must be signed in to change notification settings - Fork 12
/
run.sh
executable file
·35 lines (30 loc) · 1.05 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
JAVA_TARGET_DIR="$(cd "$(dirname $0)" && pwd)/target"
JAVA_IMAGE=registry.gitlab.com/clarin-eric/docker-alpine-supervisor-java-base:openjdk11-1.2.12
CONTAINER_CONF_FILE_PATH='/tmp/harvester.conf'
JAVA_CMD="java -Dlogdir=/logdir -jar /java-bin/oai-harvest-manager*.jar workdir=/workdir ${CONTAINER_CONF_FILE_PATH}"
WORKDIR="${WORKDIR:-$(pwd)/run/workdir}"
LOGDIR="${LOGDIR:-$(pwd)/run/log}"
CONFIG_FILE="$1"
if ! [ "${CONFIG_FILE}" ]; then
echo "Usage: $0 <config file>" >&2
exit 1
fi
if ! [ -e "${CONFIG_FILE}" ]; then
echo "File does not exist: $0" >&2
exit 1
fi
if ! [ -d "${JAVA_TARGET_DIR}" ]; then
echo "Target dir ${JAVA_TARGET_DIR} does not exist. Run build.sh first?" >&2
exit 1
fi
echo "Work dir: ${WORKDIR}"
echo "Log dir: ${LOGDIR}"
docker run -it --rm \
--name "oai-harvest-test-${RANDOM}" \
--volume "${JAVA_TARGET_DIR}:/java-bin" \
--volume "$(realpath "$CONFIG_FILE"):${CONTAINER_CONF_FILE_PATH}" \
--volume "${WORKDIR}:/workdir" \
--volume "${LOGDIR}:/logdir" \
--entrypoint bash \
"${JAVA_IMAGE}" -c "cd /workdir && ${JAVA_CMD}"