-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
54 lines (48 loc) · 1.63 KB
/
entrypoint.sh
File metadata and controls
54 lines (48 loc) · 1.63 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
49
50
51
52
53
54
#!/bin/bash
set -e
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_DIR="/workspace/grid"
GRID_PATH_CANDIDATE="${GRID_PATH:-${grid_path:-}}"
echo "Preparing grid assets..."
mkdir -p "${GRID_DIR}"
shopt -s nullglob
GRID_GEOJSON_FILES=("${GRID_DIR}"/*.geojson)
shopt -u nullglob
if [ -n "${GRID_PATH_CANDIDATE}" ] && [ -f "${GRID_PATH_CANDIDATE}" ] && [[ "${GRID_PATH_CANDIDATE}" == *.geojson ]]; then
export GRID_PATH="${GRID_PATH_CANDIDATE}"
echo "Using mounted/configured grid file: ${GRID_PATH}"
elif [ ${#GRID_GEOJSON_FILES[@]} -gt 0 ]; then
export GRID_PATH="${GRID_GEOJSON_FILES[0]}"
echo "Using existing grid file: ${GRID_PATH}"
else
echo "No .geojson grid found in ${GRID_DIR}. Generating grid on startup..."
(
cd "${GRID_DIR}"
python -m sarpyx.utils.grid
)
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 "Grid generation completed: ${GRID_PATH}"
else
echo "ERROR: Grid generation did not create any .geojson in ${GRID_DIR}" >&2
exit 1
fi
fi
# Execute the CMD passed to the container
echo "Starting main process..."
exec "$@"