Skip to content

Commit ccba607

Browse files
feiren.kuangYutong Pei
authored andcommitted
create setup node script (#76)
* change The latest version is used by default * add input Upgrade version and data dir * add change externalHost,producerPrivKey config.yml 1, install: add input externalHost, producerPrivKey config item, 2, Upgrade: get user old config ( externalHost, producerPrivKey), insert new config.yaml * add testnet flag 1, add if one args = testnet run install update testnet ;else mainnet 2,add Key information color prompt * Update setup_fullnode.sh
1 parent a4cb955 commit ccba607

File tree

1 file changed

+71
-12
lines changed

1 file changed

+71
-12
lines changed

scripts/setup_fullnode.sh

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,82 @@
11
#!/bin/bash
22

3-
##Setup Iotex TestNet
4-
##User $0 [$1]
3+
##Setup & Upgrade Iotex MainNet / TestNet
4+
##User bash/sh $0 [$1=testnet]
55

6-
version=${1:-"v0.5.0-rc10"} # if $1 ;then version=$1;else version="v0.5.0-rc8-hotfix2"
7-
echo ${version}
8-
#Pull the docker image
9-
docker pull iotex/iotex-core:${version}
106

11-
# or use gcr.io/iotex-servers/iotex-core:${version}
7+
##Input Version
8+
if [ "$1"X = "testnet"X ];then
9+
lastversion=$(curl -sS https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/README.md|grep "^- TestNet:"|awk '{print$3}')
10+
env=testnet
11+
12+
else
13+
lastversion=$(curl -sS https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/README.md|grep "^- MainNet:"|awk '{print$3}')
14+
env=mainnet
15+
fi
16+
defaultdatadir="$HOME/iotex-var"
17+
echo -e "Current operating environment: \033[41;36m $env \033[0m"
18+
read -p "Install or Upgrade Version [$lastversion]: " ver
19+
version=${ver:-"$lastversion"} # if $ver ;then version=$ver;else version=$lastversion"
20+
21+
##Input Data Dir
22+
echo "The current user of the installation directory must have write permission!!!"
23+
read -p "Install OR Upgrade Input your data dir [$defaultdatadir]: " inputdir
24+
datadir=${inputdir:-"$defaultdatadir"}
25+
26+
echo -e "Confirm version: \033[41;36m ${version} \033[0m"
27+
echo -e "Confirm Data directory: \033[41;36m ${datadir} \033[0m"
28+
read -p "Press any key to continue ... [Ctrl + c exit!] " key1
29+
export IOTEX_HOME=$datadir
30+
31+
##check iotex-server exist and running
32+
runversion=$(docker ps -a |grep "iotex/iotex-core:v"|awk '{print$2}'|awk -F'[:]' '{print$2}')
1233

34+
if [ ${runversion} ];then
35+
36+
if [ "$version"X = "$runversion"X ];then
37+
echo "Not Upgrade!! current ${runversion} is latest version"
38+
exit 0
39+
else
40+
echo "Stop old iotex-core"
41+
docker stop iotex
42+
echo "delete docker container"
43+
docker rm iotex
44+
#echo "delete iotex images"
45+
#docker rmi $(docker images iotex/iotex-core -q)
46+
producerPrivKey=$(grep '^ producerPrivKey:' ${datadir}/etc/config.yaml|sed 's/^ //g')
47+
externalHost=$(grep '^ externalHost:' ${datadir}/etc/config.yaml|sed 's/^ //g')
48+
fi
49+
50+
else
51+
mkdir -p ${datadir} && cd ${datadir} && mkdir data log etc
52+
findip=$(curl -Ss ip.sb)
53+
read -p "SET YOUR EXTERNAL IP HERE [$findip]: " inputip
54+
echo "If you are a delegate, make sure producerPrivKey is the key for the operator address you have registered."
55+
echo "SET YOUR PRIVATE KEY HERE(e.g., 96f0aa5e8523d6a28dc35c927274be4e931e74eaa720b418735debfcbfe712b8)"
56+
read -p ": " inputkey
57+
ip=${inputip:-$findip}
58+
PrivKey=${inputkey:-"96f0aa5e8523d6a28dc35c927274be4e931e74eaa720b418735debfcbfe712b8"}
59+
echo -e "Confirm your externalHost: \033[41;36m $ip \033[0m"
60+
echo -e "Confirm your producerPrivKey: \033[41;36m $PrivKey \033[0m"
61+
read -p "Press any key to continue ... [Ctrl + c exit!] " key2
62+
externalHost="externalHost: $ip"
63+
producerPrivKey="producerPrivKey: $PrivKey"
64+
fi
65+
66+
docker pull iotex/iotex-core:${version}
67+
# or use gcr.io/iotex-servers/iotex-core:${version}
1368
#Set the environment with the following commands:
14-
mkdir -p ~/iotex-var && cd ~/iotex-var && mkdir data log etc
15-
export IOTEX_HOME=$PWD
1669

17-
#mkdir -p $IOTEX_HOME/{data,log,etc}
70+
#(Optional) If you prefer to start from a snapshot, run the following commands:
71+
#curl -LSs https://t.iotex.me/${env}-data-latest > $IOTEX_HOME/data.tar.gz
72+
#cd ${IOTEX_HOME} && tar -xzf data.tar.gz
73+
curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/config_${env}.yaml > $IOTEX_HOME/etc/config.yaml
74+
curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/genesis_${env}.yaml > $IOTEX_HOME/etc/genesis.yaml
75+
1876

19-
curl https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/config_mainnet.yaml > $IOTEX_HOME/etc/config.yaml
20-
curl https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/genesis_mainnet.yaml > $IOTEX_HOME/etc/genesis.yaml
77+
echo "Update your externalHost,producerPrivKey to config.yaml"
78+
sed -i "/^network:/a\ \ $externalHost" $IOTEX_HOME/etc/config.yaml
79+
sed -i "/^chain:/a\ \ $producerPrivKey" $IOTEX_HOME/etc/config.yaml
2180

2281
#Run the following command to start a node:
2382
docker run -d --restart on-failure --name iotex \

0 commit comments

Comments
 (0)