examples: improve robustness of deploy scripts

- The scripts now work within arbitrary nix-shells.
  Previously, they failed when run from nix shells other than
  `examples/shell.nix`.

- The scripts now work from arbitrary working dirs.
This commit is contained in:
Erik Arvstedt 2021-03-16 12:45:17 +01:00
parent 4022f86b92
commit cc7149eb78
No known key found for this signature in database
GPG key ID: 33312B944DD97846
4 changed files with 12 additions and 4 deletions

View file

@ -11,10 +11,12 @@ set -euo pipefail
# MAKE SURE TO REPLACE the SSH identity file if you use this script for
# anything serious.
if [[ ! -v IN_NIX_SHELL ]]; then
if [[ ! -v NIX_BITCOIN_EXAMPLES_DIR ]]; then
echo "Running script in nix shell env..."
cd "${BASH_SOURCE[0]%/*}"
exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
else
cd "$NIX_BITCOIN_EXAMPLES_DIR"
fi
source qemu-vm/run-vm.sh