scripts: check if running from original checkout

Change-Id: I42e6b9e38a86a05c8ddbd2716ed2bd4d1db59331
Reviewed-on: https://review.monogon.dev/c/monogon/+/217
Reviewed-by: Sergiusz Bazanski <serge@nexantic.com>
diff --git a/scripts/bin/bazel b/scripts/bin/bazel
index 09cca51..d689cac 100755
--- a/scripts/bin/bazel
+++ b/scripts/bin/bazel
@@ -1,4 +1,9 @@
 #!/usr/bin/env bash
 set -euo pipefail
 
+if [[ "$(podman inspect monogon-dev --format "{{ (index .Mounts 0).Source }}")" != "$(pwd)" ]]; then
+    echo "Please run this wrapper from the original checkout"
+    exit 1
+fi
+
 exec podman exec -it monogon-dev bazel --output_user_root ${HOME}/.cache/bazel-monogon "$@"
diff --git a/scripts/bin/ibazel b/scripts/bin/ibazel
index 3c32571..b0dc474 100755
--- a/scripts/bin/ibazel
+++ b/scripts/bin/ibazel
@@ -1,6 +1,11 @@
 #!/usr/bin/env bash
 set -euo pipefail
 
+if [[ "$(podman inspect monogon-dev --format "{{ (index .Mounts 0).Source }}")" != "$(pwd)" ]]; then
+    echo "Please run this wrapper from the original checkout"
+    exit 1
+fi
+
 # ibazel doesn't take a --output_user_root, set it using the per-user .bazelrc inside the container.
 podman exec -i monogon-dev bash -c "cat - > /user/.bazelrc" <<EOF
 startup --output_user_root ${HOME}/.cache/bazel-monogon
diff --git a/scripts/run_in_container.sh b/scripts/run_in_container.sh
index 11a905e..b2d0e3d 100755
--- a/scripts/run_in_container.sh
+++ b/scripts/run_in_container.sh
@@ -1,4 +1,9 @@
 #!/usr/bin/env bash
 set -euo pipefail
 
+if [[ "$(podman inspect monogon-dev --format "{{ (index .Mounts 0).Source }}")" != "$(pwd)" ]]; then
+    echo "Please run this wrapper from the original checkout"
+    exit 1
+fi
+
 podman exec -it monogon-dev $@