-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
48 lines (42 loc) · 1.52 KB
/
entrypoint.sh
File metadata and controls
48 lines (42 loc) · 1.52 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -euo pipefail
echo "=== Container Startup Script ==="
# Update SNAP
echo "Updating SNAP..."
if [ -d "${SNAP_HOME}/bin" ]; then
if [ "${SNAP_SKIP_UPDATES:-1}" = "1" ]; then
echo "SNAP updates skipped (SNAP_SKIP_UPDATES=1)."
else
${SNAP_HOME}/bin/snap --nosplash --nogui --modules --update-all || echo "Warning: SNAP update failed"
echo "SNAP update completed."
fi
else
echo "Warning: SNAP_HOME not found at ${SNAP_HOME}"
fi
GRID_PATH_CANDIDATE="${GRID_PATH:-${grid_path:-}}"
echo "Preparing grid assets..."
if [ -n "${GRID_PATH_CANDIDATE}" ]; then
if [ -f "${GRID_PATH_CANDIDATE}" ] && [[ "${GRID_PATH_CANDIDATE}" == *.geojson ]]; then
export GRID_PATH="${GRID_PATH_CANDIDATE}"
echo "Using mounted/configured grid file: ${GRID_PATH}"
else
echo "ERROR: GRID_PATH must point to an existing .geojson file inside the container. Received: ${GRID_PATH_CANDIDATE}" >&2
exit 1
fi
else
GRID_DIR="${GRID_DIR:-/workspace/grid}"
mkdir -p "${GRID_DIR}"
shopt -s nullglob
GRID_GEOJSON_FILES=("${GRID_DIR}"/*.geojson)
shopt -u nullglob
if [ ${#GRID_GEOJSON_FILES[@]} -gt 0 ]; then
export GRID_PATH="${GRID_GEOJSON_FILES[0]}"
echo "Using existing grid file: ${GRID_PATH}"
else
echo "ERROR: No .geojson grid found in ${GRID_DIR}. Mount a grid file or set GRID_PATH to an existing in-container .geojson file." >&2
exit 1
fi
fi
# Execute the CMD passed to the container
echo "Starting main process..."
exec "$@"