askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
entrypoint.sh · 873 bytes · 27 lines
| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Entrypoint of the Linux sandbox test image (scripts/test_linux_sandbox.sh). |
| 4 | # |
| 5 | # As root it starts the test-only signal helper, then hands over to the |
| 6 | # image's real entrypoint, unchanged: that starts the sandbox launcher as |
| 7 | # root and drops to `dbbasic` for the command (the tests). |
| 8 | set -eu |
| 9 | |
| 10 | if [ "$(id -u)" = "0" ]; then |
| 11 | SOCKET=/run/dbbasic-test/signal.sock |
| 12 | PYTHON="$(command -v python)" |
| 13 | "${PYTHON}" -I -S /usr/local/lib/dbbasic-test/signal_helper.py \ |
| 14 | --socket "${SOCKET}" --client-user dbbasic --target-user dbbasic-sandbox & |
| 15 | tries=0 |
| 16 | while [ ! -S "${SOCKET}" ] && [ "${tries}" -lt 50 ]; do |
| 17 | sleep 0.1 |
| 18 | tries=$((tries + 1)) |
| 19 | done |
| 20 | if [ ! -S "${SOCKET}" ]; then |
| 21 | echo "[dbbasic-test] the signal helper did not start" >&2 |
| 22 | exit 1 |
| 23 | fi |
| 24 | export DBBASIC_TEST_SIGNAL_SOCKET="${SOCKET}" |
| 25 | fi |
| 26 | |
| 27 | exec /usr/local/bin/dbbasic-entrypoint "$@" |