42 lines
2.3 KiB
Bash
Executable File
42 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# provision_client.sh — runs provision_client.py against a target site's
|
|
# bench console, non-interactively.
|
|
#
|
|
# Usage (from the sightbox/ project root, with the stack already up):
|
|
# ./playbook/provisioning/provision_client.sh <site-name>
|
|
#
|
|
# Prerequisites this script does NOT handle (see INSTALLATION_PLAYBOOK.md):
|
|
# - The site must already exist (Stage 1-2: docker compose up, bench new-site)
|
|
# - The real Setup Wizard must already be completed (Stage 3 — never scripted).
|
|
# Confirmed the hard way: skipping it doesn't just affect Stock Entry rate
|
|
# calculations as originally documented — the same locale UnboundLocalError
|
|
# fires from ANY code path touching date formatting, which includes Server
|
|
# Script creation, so this script will fail confusingly partway through on
|
|
# an un-wizarded site, not just when running transactions afterward.
|
|
# - server_script_enabled must be true bench-wide (Stage 9, step 1) —
|
|
# this script's Server Script creation will fail loudly if it isn't
|
|
#
|
|
# Implementation note: this feeds the whole script to bench console as one
|
|
# exec() call with an explicit shared namespace (`exec(src, ns, ns)`) rather
|
|
# than piping the file directly (`bench console < file`). Confirmed the hard
|
|
# way: bench console's IPython-based execution gives top-level function
|
|
# definitions a __globals__ that doesn't match the dict they're actually
|
|
# stored in whenever globals() and locals() differ in that context (they do
|
|
# here) — sibling functions then can't find each other at call time, raising
|
|
# spurious NameErrors. Passing one explicit dict as both globals and locals
|
|
# to exec() is the standard fix.
|
|
|
|
set -euo pipefail
|
|
|
|
SITE="${1:?Usage: provision_client.sh <site-name>}"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REMOTE_PATH="/tmp/provision_client.py"
|
|
REMOTE_LOGO_PATH="/tmp/bettersight_logo.png"
|
|
|
|
echo "Provisioning native customizations onto site: ${SITE}"
|
|
docker compose cp "${SCRIPT_DIR}/provision_client.py" "backend:${REMOTE_PATH}"
|
|
docker compose cp "${SCRIPT_DIR}/bettersight_logo.png" "backend:${REMOTE_LOGO_PATH}"
|
|
printf 'ns = {}\nexec(open("%s").read(), ns, ns)\nexit()\n' "${REMOTE_PATH}" \
|
|
| docker compose exec -T backend bench --site "${SITE}" console
|
|
docker compose exec -u root backend rm -f "${REMOTE_PATH}" "${REMOTE_LOGO_PATH}" || true
|