#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Enter the controller while the Python command holds the operation lock.
set -euo pipefail
(( EUID == 0 )) || exit 1
project=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd -P)
root="$project/build/controller"
work="$project/build"
[[ -f $root/etc/debian_version ]]
account=${1:?}
shift
exec unshare --mount --pid --fork --kill-child=SIGKILL --propagation private \
    /bin/bash "$project/tools/lib/enter-root" "$root" "$work" "$account" "$@"
