| 
									
										
										
										
											2018-11-11 08:02:50 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | here=$(dirname "$0") | 
					
						
							|  |  |  | # shellcheck source=net/common.sh | 
					
						
							|  |  |  | source "$here"/common.sh | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | usage() { | 
					
						
							|  |  |  |   exitcode=0 | 
					
						
							|  |  |  |   if [[ -n "$1" ]]; then | 
					
						
							|  |  |  |     exitcode=1 | 
					
						
							|  |  |  |     echo "Error: $*" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   cat <<EOF | 
					
						
							| 
									
										
										
										
											2018-09-05 08:45:04 -07:00
										 |  |  | usage: $0 [ipAddress] [extra ssh arguments] | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | ssh into a node | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  ipAddress     - IP address of the desired node. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If ipAddress is unspecified, a list of available nodes will be displayed. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  |   exit $exitcode | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | while getopts "h?" opt; do | 
					
						
							|  |  |  |   case $opt in | 
					
						
							|  |  |  |   h | \?) | 
					
						
							|  |  |  |     usage | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   *) | 
					
						
							|  |  |  |     usage "Error: unhandled option: $opt" | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | loadConfigFile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ipAddress=$1 | 
					
						
							| 
									
										
										
										
											2018-09-05 08:45:04 -07:00
										 |  |  | shift | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | if [[ -n "$ipAddress" ]]; then | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2018-09-05 08:45:04 -07:00
										 |  |  |   exec ssh "${sshOptions[@]}" "$ipAddress" "$@" | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 12:48:06 -07:00
										 |  |  | printNode() { | 
					
						
							|  |  |  |   declare nodeType=$1 | 
					
						
							|  |  |  |   declare ip=$2 | 
					
						
							| 
									
										
										
										
											2018-09-08 19:19:12 -07:00
										 |  |  |   printf "  %-25s | For logs run: $0 $ip tail -f solana/$nodeType.log\n" "$0 $ip" | 
					
						
							| 
									
										
										
										
											2018-09-07 12:48:06 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-05 08:45:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-21 21:21:21 -06:00
										 |  |  | echo Validators: | 
					
						
							|  |  |  | for ipAddress in "${validatorIpList[@]}"; do | 
					
						
							|  |  |  |   printNode validator "$ipAddress" | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | done | 
					
						
							|  |  |  | echo | 
					
						
							|  |  |  | echo Clients: | 
					
						
							|  |  |  | if [[ ${#clientIpList[@]} -eq 0 ]]; then | 
					
						
							|  |  |  |   echo "  None" | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   for ipAddress in "${clientIpList[@]}"; do | 
					
						
							| 
									
										
										
										
											2018-09-07 12:48:06 -07:00
										 |  |  |     printNode client "$ipAddress" | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  |   done | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2018-11-11 07:55:40 -08:00
										 |  |  | echo | 
					
						
							| 
									
										
										
										
											2019-02-21 16:35:26 -07:00
										 |  |  | echo Blockstreamers: | 
					
						
							|  |  |  | if [[ ${#blockstreamerIpList[@]} -eq 0 ]]; then | 
					
						
							| 
									
										
										
										
											2019-02-17 09:48:27 -08:00
										 |  |  |   echo "  None" | 
					
						
							|  |  |  | else | 
					
						
							| 
									
										
										
										
											2019-02-21 16:35:26 -07:00
										 |  |  |   for ipAddress in "${blockstreamerIpList[@]}"; do | 
					
						
							| 
									
										
										
										
											2019-10-21 21:21:21 -06:00
										 |  |  |     printNode validator "$ipAddress" | 
					
						
							| 
									
										
										
										
											2019-02-17 09:48:27 -08:00
										 |  |  |   done | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | echo | 
					
						
							| 
									
										
										
										
											2018-11-11 07:55:40 -08:00
										 |  |  | echo "Use |scp.sh| to transfer files to and from nodes" | 
					
						
							|  |  |  | echo | 
					
						
							| 
									
										
										
										
											2018-08-28 10:19:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit 0 |