Files
lidar_rendu/start.sh
Antoine fb892ea9f2 Translate the whole project to English and fix outdated comments and help
Comments, docstrings, logs, CLI help, map UI, legends, PDF sheet, scripts,
compose files and AGENTS.md are now English. Data keys stay unchanged
(relief_oriente, densite_sol, visualisations/, API JSON keys, link params).
Wrong comments and help defaults found along the way are corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:16:45 +02:00

69 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start the LiDAR map locally with a single command (GPU optional).
#
# ./start.sh build the image and start the map (port 8973)
# ./start.sh stop stop the map
# ./start.sh logs follow the server log
# ./start.sh process [opts] one-off processing of the tiles in input/
# (options passed to the pipeline, e.g. --file NAME)
#
# Without an NVIDIA GPU usable by Docker, docker-compose.cpu.yml is added
# automatically (the pipeline then runs on the CPU, more slowly).
set -euo pipefail
cd "$(dirname "$0")"
# Create input/ and output/ as the current user: if Docker created them they
# would belong to root and the container (uid 1000) could not write to them.
mkdir -p input output
for d in input output; do
if [ ! -w "$d" ]; then
echo "Error: $d/ is not writable (owner: $(stat -c %U "$d"))." >&2
echo "Fix it with: sudo chown -R $(id -u):$(id -g) $d" >&2
exit 1
fi
done
if [ "$(id -u)" != "1000" ]; then
echo "Warning: the containers run as uid 1000, you are $(id -u):" >&2
echo "input/ and output/ must stay writable by uid 1000." >&2
fi
# GPU: nvidia-smi present AND Docker able to hand it to a container.
compose=(docker compose -f docker-compose.yml)
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1 \
&& docker run --rm --gpus all --entrypoint true busybox >/dev/null 2>&1; then
echo "NVIDIA GPU detected: accelerated processing."
else
echo "No usable GPU: processing on the CPU (slower)."
compose+=(-f docker-compose.cpu.yml)
fi
case "${1:-up}" in
up)
"${compose[@]}" up -d --build serve
echo "Map: http://localhost:8973/"
echo "Log: ./start.sh logs - stop: ./start.sh stop"
;;
stop)
"${compose[@]}" down
;;
logs)
"${compose[@]}" logs -f serve
;;
process)
shift
if [ $# -gt 0 ]; then
# Any option replaces the service's default command: repeat it in
# full (input, output, 0.2 m, all GPUs).
"${compose[@]}" run --rm --build process \
python3 -m lidar_pipeline /data/input -o /data/output -r 0.2 -g all "$@"
else
"${compose[@]}" run --rm --build process
fi
;;
*)
sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//'
exit 1
;;
esac