Merge #178: examples: execute bash sessions in script environment

0f1ee5f533 examples: improve shell session usability (Erik Arvstedt)
719dcd77bb examples: execute bash sessions in script environment (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 0f1ee5f533

Tree-SHA512: efaa79b345628026543d3cd7c5449390707a189849d9b375604e319beaf8cd656e554e6097a5a317713713ebfae85464d05a469f12d9aa23d79c685232f1c5c9
This commit is contained in:
Jonas Nick 2020-05-18 06:44:00 +00:00
commit ca7f287f6d
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
4 changed files with 26 additions and 4 deletions

View File

@ -62,7 +62,13 @@ in {
} }
EOF EOF
# Run command in container # Run command in container
c() { sudo extra-container run demo-node -- "$@" | cat; } c() {
if [[ $# > 0 ]]; then
sudo extra-container run demo-node -- "$@" | cat;
else
sudo nixos-container root-login demo-node
fi
}
echo echo
echo "Bitcoind service:" echo "Bitcoind service:"
@ -81,6 +87,6 @@ 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
# Uncomment to start a shell session here # Uncomment to start a shell session here
# export -f c; bash -li # . start-bash-session.sh
# Cleanup happens at exit (see above) # Cleanup happens at exit (see above)

View File

@ -38,7 +38,8 @@ nixops deploy -d bitcoin-node
# Connect to node # Connect to node
nixops ssh bitcoin-node systemctl status bitcoind nixops ssh bitcoin-node systemctl status bitcoind
c() { nixops ssh bitcoin-node "$@"; }
# Uncomment to start a shell session here # Uncomment to start a shell session here
# bash -li # . start-bash-session.sh
# Cleanup happens at exit (see above) # Cleanup happens at exit (see above)

View File

@ -91,6 +91,6 @@ echo "Node info:"
c nodeinfo c nodeinfo
# Uncomment to start a shell session here # Uncomment to start a shell session here
# export -f c; bash -li # . start-bash-session.sh
# Cleanup happens at exit (see above) # Cleanup happens at exit (see above)

View File

@ -0,0 +1,15 @@
# Start an interactive bash session in the current bash environment.
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'
# BASH_ENVIRONMENT contains definitions of read-only variables like 'BASHOPTS' that
# cause warnings on evaluation. Suppress these warnings while sourcing.
BASH_ENVIRONMENT=<(declare -p; declare -pf) \
USAGE_INFO="$USAGE_INFO" \
bash --rcfile <(echo '
source $BASH_ENVIRONMENT 2>/dev/null
echo "$USAGE_INFO"
')