examples: add option --interactive|-i

This commit is contained in:
Erik Arvstedt 2020-10-18 13:41:55 +02:00
parent 33ff8d82be
commit c19f7ebb01
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
5 changed files with 33 additions and 16 deletions

View File

@ -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.\ NixOps can be used to deploy to various other backends like cloud providers.\
Requires: [Nix](https://nixos.org/nix/), [VirtualBox](https://www.virtualbox.org) 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 #### Tests
The internal test suite is also useful for exploring features. The internal test suite is also useful for exploring features.
The following `run-tests.sh` commands leave no traces (outside of `/nix/store`) on The following `run-tests.sh` commands leave no traces (outside of `/nix/store`) on

View File

@ -17,12 +17,9 @@ fi
if [[ ! -v IN_NIX_SHELL ]]; then if [[ ! -v IN_NIX_SHELL ]]; then
echo "Running script in nix shell env..." echo "Running script in nix shell env..."
cd "${BASH_SOURCE[0]%/*}" cd "${BASH_SOURCE[0]%/*}"
exec nix-shell --run "./${BASH_SOURCE[0]##*/}" exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
fi fi
# Uncomment to start a container shell session
# interactive=1
# These commands can also be executed interactively in a shell session # These commands can also be executed interactively in a shell session
demoCmds=' demoCmds='
echo echo
@ -42,11 +39,14 @@ echo "Bitcoind data dir:"
sudo ls -al /var/lib/containers/demo-node/var/lib/bitcoind sudo ls -al /var/lib/containers/demo-node/var/lib/bitcoind
' '
if [[ ${interactive:-} ]]; then case ${1:-} in
runCmd= -i|--interactive)
else runCmd=
runCmd=(--run bash -c "$demoCmds") ;;
fi *)
runCmd=(--run bash -c "$demoCmds")
;;
esac
# Build container. # Build container.
# Learn more: https://github.com/erikarvstedt/extra-container # Learn more: https://github.com/erikarvstedt/extra-container

View File

@ -11,7 +11,7 @@ set -euo pipefail
if [[ ! -v IN_NIX_SHELL ]]; then if [[ ! -v IN_NIX_SHELL ]]; then
echo "Running script in nix shell env..." echo "Running script in nix shell env..."
cd "${BASH_SOURCE[0]%/*}" cd "${BASH_SOURCE[0]%/*}"
exec nix-shell --run "./${BASH_SOURCE[0]##*/}" exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
fi fi
# Cleanup on exit # Cleanup on exit
@ -40,7 +40,11 @@ nixops deploy -d bitcoin-node
nixops ssh bitcoin-node systemctl status bitcoind nixops ssh bitcoin-node systemctl status bitcoind
c() { nixops ssh bitcoin-node "$@"; } 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) # Cleanup happens at exit (see above)

View File

@ -14,7 +14,7 @@ set -euo pipefail
if [[ ! -v IN_NIX_SHELL ]]; then if [[ ! -v IN_NIX_SHELL ]]; then
echo "Running script in nix shell env..." echo "Running script in nix shell env..."
cd "${BASH_SOURCE[0]%/*}" cd "${BASH_SOURCE[0]%/*}"
exec nix-shell --run "./${BASH_SOURCE[0]##*/}" exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
fi fi
tmpDir=/tmp/nix-bitcoin-qemu-vm tmpDir=/tmp/nix-bitcoin-qemu-vm
@ -91,7 +91,10 @@ echo
echo "Node info:" echo "Node info:"
c nodeinfo c nodeinfo
# Uncomment to start a shell session here case ${1:-} in
# . start-bash-session.sh -i|--interactive)
. start-bash-session.sh
;;
esac
# Cleanup happens at exit (see above) # Cleanup happens at exit (see above)

View File

@ -3,7 +3,11 @@
USAGE_INFO=' USAGE_INFO='
Starting shell... Starting shell...
Run "c COMMAND" to execute a command on the bitcoin node 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 # BASH_ENVIRONMENT contains definitions of read-only variables like 'BASHOPTS' that
# cause warnings on evaluation. Suppress these warnings while sourcing. # cause warnings on evaluation. Suppress these warnings while sourcing.