github.com/aergoio/aergo@v1.3.1/consensus/impl/raftv2/test/init_genesis.sh (about)

     1  #!/usr/bin/env bash
     2  if [ $# != 1 ]; then
     3      echo "Usage: $0 <bpname>"
     4      exit 100
     5  fi
     6  
     7  bpname=$1
     8  newpassword="1234"
     9  
    10  
    11  if [[ $bpname =~ "BP*" ]]; then
    12  	echo "Err: bpname($bpname) must have BP*"
    13  	exit 100
    14  fi
    15  
    16  if [ ! -e genesis -o ! -e genesis.json ]; then 
    17  	echo "no genesis file"
    18  	clean.sh
    19  
    20  	wallet=`aergocli account new --password 1234 --path genesis `
    21  
    22  	echo "create genesis wallet : $wallet" 
    23  	echo "$wallet" > genesis_wallet.txt
    24  
    25  	wif=`aergocli account export --address ${wallet} --password 1234 --path genesis `
    26  
    27  	echo "export wif : $wif"
    28  	echo $wif > ./wif.txt
    29  
    30  	sed  -e "s/_genesis_wallet_/${wallet}/g" _genesis.json > genesis.json
    31  else
    32  	echo "use prev genesis file"
    33  	wallet=$(cat ./genesis_wallet.txt)
    34      wif=$(cat ./wif.txt)
    35  fi
    36  
    37  
    38  # make toml
    39  #aergoconf-gen.sh $1 $2 $3
    40  
    41  
    42  # genesis block patch
    43  
    44  PWD=$(pwd)
    45  
    46  file="${bpname}.toml"
    47  echo "config=$file"
    48  BP_NAME=$bpname
    49  if [ "${BP_NAME}" != "tmpl" -a "${BP_NAME}" != "arglog" ]; then
    50  	 N_NAME=${BP_NAME#BP}
    51  	 N_PORT=$((${N_NAME}-1000))
    52  
    53  	DATADIR="$PWD/data/$N_NAME"
    54  	echo "datadir=$DATADIR"
    55  
    56  	echo "init genesis block "
    57  	echo "aergosvr init --genesis ./genesis.json --home ${PWD} --config ./$file"
    58  	aergosvr init --genesis ./genesis.json --home ${PWD} --config ./$file
    59  
    60  	echo "import wallet ${wallet} to ${N_NAME} from local"
    61  	echo "aergocli account import --if ${wif} --password 1234 --path ${DATADIR}"
    62  	aergocli account import --if ${wif} --password 1234 --path ${DATADIR} 
    63  
    64  	echo "start server ${BP_NAME} "
    65  	echo "aergosvr --home ${PWD} --config ./$file >> server_${BP_NAME}.log 2>&1 &"
    66  #nohup aergosvr --home ${PWD} --config ./$file >> server_${BP_NAME}.log 2>&1 &
    67  	nohup aergosvr --home ${PWD} --config ./$file >> server_${BP_NAME}.log 2>&1 &
    68  
    69  	echo "sleep 3s to wait boot"
    70  	sleep 3
    71  
    72  	echo "unlock account ${wallet} "
    73  	echo "aergocli -p ${N_PORT} getstate --address ${wallet}"
    74  	aergocli -p ${N_PORT} getstate --address ${wallet}
    75  	echo  "aergocli -p ${N_PORT} account unlock --address ${wallet} --password 1234"
    76  	aergocli -p ${N_PORT} account unlock --address ${wallet} --password 1234 
    77  	echo "aergocli -p ${N_PORT} account list"
    78  	aergocli -p ${N_PORT} account list
    79  fi