| 
									
										
										
										
											2018-11-11 08:02:50 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2018-08-27 09:13:53 -07:00
										 |  |  | # | 
					
						
							|  |  |  | # Creates a fullnode configuration | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-23 11:52:12 -07:00
										 |  |  | here=$(dirname "$0") | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | # shellcheck source=multinode-demo/common.sh | 
					
						
							|  |  |  | source "$here"/common.sh | 
					
						
							| 
									
										
										
										
											2018-06-23 11:52:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  | usage () { | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |   exitcode=0 | 
					
						
							|  |  |  |   if [[ -n "$1" ]]; then | 
					
						
							|  |  |  |     exitcode=1 | 
					
						
							|  |  |  |     echo "Error: $*" | 
					
						
							|  |  |  |   fi | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  |   cat <<EOF | 
					
						
							| 
									
										
										
										
											2019-03-05 17:01:57 -08:00
										 |  |  | usage: $0 [-n lamports] [-l] [-p] [-t node_type] | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | Creates a fullnode configuration | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-05 17:01:57 -08:00
										 |  |  |  -n lamports    - Number of lamports to create | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |  -t node_type   - Create configuration files only for this kind of node.  Valid | 
					
						
							| 
									
										
										
										
											2018-12-07 15:59:25 -08:00
										 |  |  |                   options are bootstrap-leader or fullnode.  Creates configuration files | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |                   for both by default | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  | EOF | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |   exit $exitcode | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-05 17:01:57 -08:00
										 |  |  | lamports=1000000000 | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  | bootstrap_leader=true | 
					
						
							|  |  |  | fullnode=true | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  | while getopts "h?n:lpt:" opt; do | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  |   case $opt in | 
					
						
							|  |  |  |   h|\?) | 
					
						
							|  |  |  |     usage | 
					
						
							|  |  |  |     exit 0 | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   n) | 
					
						
							| 
									
										
										
										
											2019-03-05 17:01:57 -08:00
										 |  |  |     lamports="$OPTARG" | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |   t) | 
					
						
							|  |  |  |     node_type="$OPTARG" | 
					
						
							|  |  |  |     case $OPTARG in | 
					
						
							| 
									
										
										
										
											2018-12-07 15:59:25 -08:00
										 |  |  |     bootstrap-leader|leader) # TODO: Remove legacy 'leader' option | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  |       bootstrap_leader=true | 
					
						
							|  |  |  |       fullnode=false | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |       ;; | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  |     fullnode|validator) # TODO: Remove legacy 'validator' option | 
					
						
							|  |  |  |       bootstrap_leader=false | 
					
						
							|  |  |  |       fullnode=true | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  |       ;; | 
					
						
							|  |  |  |     *) | 
					
						
							|  |  |  |       usage "Error: unknown node type: $node_type" | 
					
						
							|  |  |  |       ;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   *) | 
					
						
							|  |  |  |     usage "Error: unhandled option: $opt" | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2018-06-28 16:08:59 -07:00
										 |  |  |   esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | set -e | 
					
						
							| 
									
										
										
										
											2018-06-18 15:23:56 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  | for i in "$SOLANA_RSYNC_CONFIG_DIR" "$SOLANA_CONFIG_DIR"; do | 
					
						
							| 
									
										
										
										
											2018-09-13 17:58:33 -07:00
										 |  |  |   echo "Cleaning $i" | 
					
						
							|  |  |  |   rm -rvf "$i" | 
					
						
							|  |  |  |   mkdir -p "$i" | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  | if $bootstrap_leader; then | 
					
						
							|  |  |  |   # Create genesis configuration | 
					
						
							|  |  |  |   ( | 
					
						
							|  |  |  |     set -x | 
					
						
							|  |  |  |     $solana_keygen -o "$SOLANA_CONFIG_DIR"/mint-id.json | 
					
						
							|  |  |  |     $solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json | 
					
						
							| 
									
										
										
										
											2019-03-08 18:29:08 -08:00
										 |  |  |     $solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  |     $solana_genesis \
 | 
					
						
							|  |  |  |       --bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json \
 | 
					
						
							|  |  |  |       --ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \
 | 
					
						
							|  |  |  |       --mint "$SOLANA_CONFIG_DIR"/mint-id.json \
 | 
					
						
							| 
									
										
										
										
											2019-03-05 17:01:57 -08:00
										 |  |  |       --lamports "$lamports" | 
					
						
							| 
									
										
										
										
											2018-12-07 11:34:14 -07:00
										 |  |  |     cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  |   ) | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  | if $fullnode; then | 
					
						
							|  |  |  |   ( | 
					
						
							|  |  |  |     set -x | 
					
						
							|  |  |  |     $solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-id.json | 
					
						
							| 
									
										
										
										
											2019-03-08 18:29:08 -08:00
										 |  |  |     $solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-staker-id.json | 
					
						
							| 
									
										
										
										
											2018-12-06 13:38:45 -08:00
										 |  |  |   ) | 
					
						
							| 
									
										
										
										
											2018-07-02 08:08:14 -07:00
										 |  |  | fi |