ssh.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. here=$(dirname "$0")
  3. # shellcheck source=net/common.sh
  4. source "$here"/common.sh
  5. usage() {
  6. exitcode=0
  7. if [[ -n "$1" ]]; then
  8. exitcode=1
  9. echo "Error: $*"
  10. fi
  11. cat <<EOF
  12. usage: $0 [ipAddress] [extra ssh arguments]
  13. ssh into a node
  14. ipAddress - IP address of the desired node.
  15. If ipAddress is unspecified, a list of available nodes will be displayed.
  16. EOF
  17. exit $exitcode
  18. }
  19. while getopts "h?" opt; do
  20. case $opt in
  21. h | \?)
  22. usage
  23. ;;
  24. *)
  25. usage "Error: unhandled option: $opt"
  26. ;;
  27. esac
  28. done
  29. loadConfigFile
  30. ipAddress=$1
  31. shift
  32. if [[ -n "$ipAddress" ]]; then
  33. set -x
  34. exec ssh "${sshOptions[@]}" "$ipAddress" "$@"
  35. fi
  36. printNode() {
  37. declare nodeType=$1
  38. declare ip=$2
  39. printf " %-25s | For logs run: $0 $ip tail -f solana/$nodeType.log\n" "$0 $ip"
  40. }
  41. echo Validators:
  42. for ipAddress in "${validatorIpList[@]}"; do
  43. printNode validator "$ipAddress"
  44. done
  45. echo
  46. echo Clients:
  47. if [[ ${#clientIpList[@]} -eq 0 ]]; then
  48. echo " None"
  49. else
  50. for ipAddress in "${clientIpList[@]}"; do
  51. printNode client "$ipAddress"
  52. done
  53. fi
  54. echo
  55. echo Blockstreamers:
  56. if [[ ${#blockstreamerIpList[@]} -eq 0 ]]; then
  57. echo " None"
  58. else
  59. for ipAddress in "${blockstreamerIpList[@]}"; do
  60. printNode validator "$ipAddress"
  61. done
  62. fi
  63. echo
  64. echo "Use |scp.sh| to transfer files to and from nodes"
  65. echo
  66. exit 0