mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-30 18:46:40 +00:00
The four setup messages were in Spanish and one told the reader Python 3 was needed "en el Mac", which is the wrong machine for a script the README documents as running on the Proxmox host. They stay outside translate(): this script runs before the Python environment it is preparing exists, so no catalogue is available yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
41 lines
1.3 KiB
Bash
Executable File
41 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
VENV_DIR="$ROOT_DIR/.venv"
|
|
REQUIREMENTS="$ROOT_DIR/requirements.txt"
|
|
STAMP="$VENV_DIR/.requirements.sha256"
|
|
|
|
command -v python3 >/dev/null 2>&1 || {
|
|
echo "ERROR: Python 3 is required." >&2
|
|
exit 1
|
|
}
|
|
|
|
if python3 -c 'import yaml, jsonschema' >/dev/null 2>&1; then
|
|
PYTHON=python3
|
|
else
|
|
if [[ ! -x "$VENV_DIR/bin/python" ]] || ! "$VENV_DIR/bin/python" -m pip --version >/dev/null 2>&1; then
|
|
echo "Preparing the local Python environment..."
|
|
rm -rf "$VENV_DIR"
|
|
python3 -m venv "$VENV_DIR" || {
|
|
echo "ERROR: could not create the virtual environment. On Debian, install python3-venv, python3-yaml and python3-jsonschema." >&2
|
|
exit 1
|
|
}
|
|
fi
|
|
if command -v shasum >/dev/null 2>&1; then
|
|
CURRENT_HASH=$(shasum -a 256 "$REQUIREMENTS" | awk '{print $1}')
|
|
else
|
|
CURRENT_HASH=$(sha256sum "$REQUIREMENTS" | awk '{print $1}')
|
|
fi
|
|
INSTALLED_HASH=$(cat "$STAMP" 2>/dev/null || true)
|
|
if [[ "$CURRENT_HASH" != "$INSTALLED_HASH" ]]; then
|
|
echo "Installing the converter dependencies..."
|
|
"$VENV_DIR/bin/python" -m pip install --disable-pip-version-check -r "$REQUIREMENTS"
|
|
printf '%s\n' "$CURRENT_HASH" >"$STAMP"
|
|
fi
|
|
PYTHON="$VENV_DIR/bin/python"
|
|
fi
|
|
|
|
export PYTHONPATH="$ROOT_DIR/src${PYTHONPATH:+:$PYTHONPATH}"
|
|
exec "$PYTHON" -m proxmenux_oci "$@"
|