diff --git a/README.md b/README.md index b7242f7..c064cc6 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,12 @@ shut down immediately. They leave no traces (outside of `/nix/store`) on the hos NixOps can be used to deploy to various other backends like cloud providers.\ Requires: [Nix](https://nixos.org/nix/), [VirtualBox](https://www.virtualbox.org) +Run the examples with option `--interactive` or `-i` to start a shell for interacting with +the node: +```bash +./deploy-qemu-vm.sh -i +``` + #### Tests The internal test suite is also useful for exploring features. The following `run-tests.sh` commands leave no traces (outside of `/nix/store`) on diff --git a/examples/deploy-container.sh b/examples/deploy-container.sh index 1cc1030..17c3496 100755 --- a/examples/deploy-container.sh +++ b/examples/deploy-container.sh @@ -17,12 +17,9 @@ fi if [[ ! -v IN_NIX_SHELL ]]; then echo "Running script in nix shell env..." cd "${BASH_SOURCE[0]%/*}" - exec nix-shell --run "./${BASH_SOURCE[0]##*/}" + exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*" fi -# Uncomment to start a container shell session -# interactive=1 - # These commands can also be executed interactively in a shell session demoCmds=' echo @@ -42,11 +39,14 @@ echo "Bitcoind data dir:" sudo ls -al /var/lib/containers/demo-node/var/lib/bitcoind ' -if [[ ${interactive:-} ]]; then - runCmd= -else - runCmd=(--run bash -c "$demoCmds") -fi +case ${1:-} in + -i|--interactive) + runCmd= + ;; + *) + runCmd=(--run bash -c "$demoCmds") + ;; +esac # Build container. # Learn more: https://github.com/erikarvstedt/extra-container diff --git a/examples/deploy-nixops.sh b/examples/deploy-nixops.sh index 1f54901..568bbcd 100755 --- a/examples/deploy-nixops.sh +++ b/examples/deploy-nixops.sh @@ -11,7 +11,7 @@ set -euo pipefail if [[ ! -v IN_NIX_SHELL ]]; then echo "Running script in nix shell env..." cd "${BASH_SOURCE[0]%/*}" - exec nix-shell --run "./${BASH_SOURCE[0]##*/}" + exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*" fi # Cleanup on exit @@ -40,7 +40,11 @@ nixops deploy -d bitcoin-node nixops ssh bitcoin-node systemctl status bitcoind c() { nixops ssh bitcoin-node "$@"; } -# Uncomment to start a shell session here -# . start-bash-session.sh + +case ${1:-} in + -i|--interactive) + . start-bash-session.sh + ;; +esac # Cleanup happens at exit (see above) diff --git a/examples/deploy-qemu-vm.sh b/examples/deploy-qemu-vm.sh index 6a7541f..e155126 100755 --- a/examples/deploy-qemu-vm.sh +++ b/examples/deploy-qemu-vm.sh @@ -14,7 +14,7 @@ set -euo pipefail if [[ ! -v IN_NIX_SHELL ]]; then echo "Running script in nix shell env..." cd "${BASH_SOURCE[0]%/*}" - exec nix-shell --run "./${BASH_SOURCE[0]##*/}" + exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*" fi tmpDir=/tmp/nix-bitcoin-qemu-vm @@ -91,7 +91,10 @@ echo echo "Node info:" c nodeinfo -# Uncomment to start a shell session here -# . start-bash-session.sh +case ${1:-} in + -i|--interactive) + . start-bash-session.sh + ;; +esac # Cleanup happens at exit (see above) diff --git a/examples/start-bash-session.sh b/examples/start-bash-session.sh index 37ba4fc..a91d91f 100644 --- a/examples/start-bash-session.sh +++ b/examples/start-bash-session.sh @@ -3,7 +3,11 @@ USAGE_INFO=' Starting shell... Run "c COMMAND" to execute a command on the bitcoin node -Run "c" to start a shell session inside the node' +Run "c" to start a shell session inside the node + +Example: +c systemctl status bitcoind +' # BASH_ENVIRONMENT contains definitions of read-only variables like 'BASHOPTS' that # cause warnings on evaluation. Suppress these warnings while sourcing.