Skip to content

change The latest version is used by default #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 71 additions & 12 deletions scripts/setup_fullnode.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,82 @@
#!/bin/bash

##Setup Iotex TestNet
##User $0 [$1]
##Setup & Upgrade Iotex MainNet / TestNet
##User bash/sh $0 [$1=testnet]

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

# or use gcr.io/iotex-servers/iotex-core:${version}
##Input Version
if [ "$1"X = "testnet"X ];then
lastversion=$(curl -sS https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/README.md|grep "^- TestNet:"|awk '{print$3}')
env=testnet

else
lastversion=$(curl -sS https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/README.md|grep "^- MainNet:"|awk '{print$3}')
env=mainnet
fi
defaultdatadir="$HOME/iotex-var"
echo -e "Current operating environment: \033[41;36m $env \033[0m"
read -p "Install or Upgrade Version [$lastversion]: " ver
version=${ver:-"$lastversion"} # if $ver ;then version=$ver;else version=$lastversion"

##Input Data Dir
echo "The current user of the installation directory must have write permission!!!"
read -p "Install OR Upgrade Input your data dir [$defaultdatadir]: " inputdir
datadir=${inputdir:-"$defaultdatadir"}

echo -e "Confirm version: \033[41;36m ${version} \033[0m"
echo -e "Confirm Data directory: \033[41;36m ${datadir} \033[0m"
read -p "Press any key to continue ... [Ctrl + c exit!] " key1
export IOTEX_HOME=$datadir

##check iotex-server exist and running
runversion=$(docker ps -a |grep "iotex/iotex-core:v"|awk '{print$2}'|awk -F'[:]' '{print$2}')

if [ ${runversion} ];then

if [ "$version"X = "$runversion"X ];then
echo "Not Upgrade!! current ${runversion} is latest version"
exit 0
else
echo "Stop old iotex-core"
docker stop iotex
echo "delete docker container"
docker rm iotex
#echo "delete iotex images"
#docker rmi $(docker images iotex/iotex-core -q)
producerPrivKey=$(grep '^ producerPrivKey:' ${datadir}/etc/config.yaml|sed 's/^ //g')
externalHost=$(grep '^ externalHost:' ${datadir}/etc/config.yaml|sed 's/^ //g')
fi

else
mkdir -p ${datadir} && cd ${datadir} && mkdir data log etc
findip=$(curl -Ss ip.sb)
read -p "SET YOUR EXTERNAL IP HERE [$findip]: " inputip
echo "If you are a delegate, make sure producerPrivKey is the key for the operator address you have registered."
echo "SET YOUR PRIVATE KEY HERE(e.g., 96f0aa5e8523d6a28dc35c927274be4e931e74eaa720b418735debfcbfe712b8)"
read -p ": " inputkey
ip=${inputip:-$findip}
PrivKey=${inputkey:-"96f0aa5e8523d6a28dc35c927274be4e931e74eaa720b418735debfcbfe712b8"}
echo -e "Confirm your externalHost: \033[41;36m $ip \033[0m"
echo -e "Confirm your producerPrivKey: \033[41;36m $PrivKey \033[0m"
read -p "Press any key to continue ... [Ctrl + c exit!] " key2
externalHost="externalHost: $ip"
producerPrivKey="producerPrivKey: $PrivKey"
fi

docker pull iotex/iotex-core:${version}
# or use gcr.io/iotex-servers/iotex-core:${version}
#Set the environment with the following commands:
mkdir -p ~/iotex-var && cd ~/iotex-var && mkdir data log etc
export IOTEX_HOME=$PWD

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


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

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