Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/okikio/sparql-client. jsr.io/@okikio/sparql
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106#!/bin/bash
set -euo pipefail
# Tweak indexingSHOULD_INDEX="${SHOULD_INDEX:-false}"FORCE_INDEXING="${FORCE_INDEXING:-false}"
# Tweak data downloadSHOULD_DOWNLOAD="${SHOULD_DOWNLOAD:-true}"FORCE_DOWNLOAD="${FORCE_DOWNLOAD:-false}"
# Additional parameters to qlever start (e.g. --kill-existing-with-same-port)START_ADDITIONAL_ARGS="${START_ADDITIONAL_ARGS:-}"
# Display some debug informationecho "INFO: Indexing : should index = ${SHOULD_INDEX} ; force indexing = ${FORCE_INDEXING}"echo "INFO: Data download : should download = ${SHOULD_DOWNLOAD} ; force download = ${FORCE_DOWNLOAD}"
# Wait briefly for /data to become writable (named volumes are often root-owned at first).echo "UID=$(id -u)"echo "GID=$(id -g)"ls -al /
# Generate Qleverfile (or skip, depending on QLEVER_GENERATE_CONFIG_FILE)/bin/sh /qlever/scripts/generate-qleverfile.sh
# Go to the data directorycd /data
QLEVER_FILE_PATH="${QLEVER_FILE_PATH:-/data/Qleverfile}"
# Check if the Qleverfile existsif [ ! -f "${QLEVER_FILE_PATH}" ]; then echo "ERROR: Qleverfile not found at '${QLEVER_FILE_PATH}'" exit 1fi
# Display the Qleverfile for debuggingecho "INFO: Qleverfile found at '${QLEVER_FILE_PATH}'"cat "${QLEVER_FILE_PATH}"
# Extract INPUT_FILES from the Qleverfile (if any)INPUT_FILES=$(grep "^INPUT_FILES[[:space:]]*=" "${QLEVER_FILE_PATH}" | head -n1 | sed 's/.*=[[:space:]]*//')HAS_INPUT_FILES=$(echo "${INPUT_FILES}" | sed '/^[[:space:]]*$/d' | wc -l)
if [ "${HAS_INPUT_FILES}" -ne 0 ]; then echo "INFO: Found 'INPUT_FILES' in the Qleverfile"
# Check if the input files already exist HAS_MISSING_INPUT_FILES="false" for INPUT_FILE in ${INPUT_FILES}; do if [ -f "${INPUT_FILE}" ]; then echo "INFO: Input file found at '${INPUT_FILE}'" else echo "INFO: Input file not found at '${INPUT_FILE}'" HAS_MISSING_INPUT_FILES="true" fi done
# If all files are present, skip the download if [ "${HAS_MISSING_INPUT_FILES}" = "false" ]; then SHOULD_DOWNLOAD="false" # As the input files are already present, no need to download them fi
# Display the info in the logs only if the download is enabled if [ "${SHOULD_DOWNLOAD}" = "true" ]; then echo "INFO: Trigger download of input files…" fifi
# If the download of the input files is forced, then download them in all casesif [ "${FORCE_DOWNLOAD}" = "true" ]; then echo "INFO: Forcing download of input files…" SHOULD_DOWNLOAD="true"fi
# Check if there is a line that starts with `GET_DATA_CMD` in the Qleverfileif grep -q "^GET_DATA_CMD" "${QLEVER_FILE_PATH}"; then echo "INFO: Found 'GET_DATA_CMD' in the Qleverfile" if [ "${SHOULD_DOWNLOAD}" = "true" ]; then echo "INFO: Trigger download of data…" qlever get-data SHOULD_INDEX="true" # As the data is downloaded, we should index it else echo "INFO: Skipping download of data…" fifi
# Indexing logicif [ "${SHOULD_INDEX}" = "true" ]; then echo "INFO: Indexing is enabled" qlever index --overwrite-existingelif [ "${FORCE_INDEXING}" = "true" ]; then echo "INFO: Forcing indexing" qlever index --overwrite-existingelse echo "INFO: Indexing is disabled"fi
# Start the QLever serverecho "INFO: Starting QLever server..."
# Normal case: keep QLever in the foreground, container stays aliveexec qlever start --run-in-foreground $START_ADDITIONAL_ARGS