Skip to content

Instantly share code, notes, and snippets.

@thanhson1085
Created July 3, 2021 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thanhson1085/912c0042366f91feafd4a5fc54be37ee to your computer and use it in GitHub Desktop.
Save thanhson1085/912c0042366f91feafd4a5fc54be37ee to your computer and use it in GitHub Desktop.
#!/bin/bash
touch .pwd
export $(cat .env | xargs)
WORK_DIR=$PWD
WS_SECRET="${WS_SECRET:-bgfmsp2r7TgIYA2HW48SkBQE6L4CUc}"
TOMOCHAIN_DIR="${TOMOCHAIN_DIR:-${HOME}/go/src/github.com/tomochain/tomochain}"
TOMOXSDK_DIR="${TOMOXSDK_DIR:-${HOME}/go/src/github.com/tomochain/tomox-sdk}"
BOT_DIR="${BOT_DIR:-${HOME}/tomox-market-maker}"
TOMORELAYER_DIR="${TOMORELAYER_DIR:-${HOME}/tomorelayer}"
WALLET_DIR="${WALLET_DIR:-${HOME}/tomowallet-web}"
SCAN_DIR="${SCAN_DIR:-${HOME}/tomoscan}"
MASTER_DIR="${MASTER_DIR:-${HOME}/tomomaster}"
FAUCET_DIR="${FAUCET_DIR:-${HOME}/faucet}"
PRIVACY_SC_DIR="${PRIVACY_SC_DIR:-${HOME}/privacy-sc}"
PRIVACYJS_DIR="${PRIVACYJS_DIR:-${HOME}/privacyjs}"
cd $TOMOCHAIN_DIR && make all
cd $WORK_DIR
ISRESET=false
if [ ! -d ./nodes/1/tomo/chaindata ]
then
ISRESET=true
wallet1=$(${TOMOCHAIN_DIR}/build/bin/tomo account import --password .pwd --datadir ./nodes/1 <(echo ${PRIVATE_KEY_1}) | awk -v FS="({|})" '{print $2}')
wallet2=$(${TOMOCHAIN_DIR}/build/bin/tomo account import --password .pwd --datadir ./nodes/2 <(echo ${PRIVATE_KEY_2}) | awk -v FS="({|})" '{print $2}')
wallet3=$(${TOMOCHAIN_DIR}/build/bin/tomo account import --password .pwd --datadir ./nodes/3 <(echo ${PRIVATE_KEY_3}) | awk -v FS="({|})" '{print $2}')
wallet7=$(${TOMOCHAIN_DIR}/build/bin/tomo account import --password .pwd --datadir ./nodes/7 <(echo ${PRIVATE_KEY_7}) | awk -v FS="({|})" '{print $2}')
${TOMOCHAIN_DIR}/build/bin/tomo --datadir ./nodes/1 init ./genesis/testnet.json
${TOMOCHAIN_DIR}/build/bin/tomo --datadir ./nodes/2 init ./genesis/testnet.json
${TOMOCHAIN_DIR}/build/bin/tomo --datadir ./nodes/3 init ./genesis/testnet.json
${TOMOCHAIN_DIR}/build/bin/tomo --datadir ./nodes/7 init ./genesis/testnet.json
else
wallet1=$(${TOMOCHAIN_DIR}/build/bin/tomo account list --datadir ./nodes/1 | head -n 1 | awk -v FS="({|})" '{print $2}')
wallet2=$(${TOMOCHAIN_DIR}/build/bin/tomo account list --datadir ./nodes/2 | head -n 1 | awk -v FS="({|})" '{print $2}')
wallet3=$(${TOMOCHAIN_DIR}/build/bin/tomo account list --datadir ./nodes/3 | head -n 1 | awk -v FS="({|})" '{print $2}')
wallet7=$(${TOMOCHAIN_DIR}/build/bin/tomo account list --datadir ./nodes/7 | head -n 1 | awk -v FS="({|})" '{print $2}')
fi
VERBOSITY="${VERBOSITY:-3}"
NETWORKID="${NETWORKID:-89}"
GASPRICE="${GASPRICE:-250000000}"
BOOTNODES="enode://ba966140e161ad416a7bd7c75dc695e0a41232723e2b19cbbf651883ef5e8f2528801b17b9d63152814d219a58a4fcc3e3c877486e64057523f6714092348efa@127.0.0.1:30301"
echo Starting netstats ...
if [ "$(docker ps -aq -f name=netstats)" ]; then
if [ ! "$(docker ps -aq -f 'status=running' -f name=netstats)" ]; then
docker start netstats
fi
else
docker run -d --env WS_SECRET=$WS_SECRET --name netstats -p 3004:3000 tomochain/netstats:latest
fi
echo Starting the bootnode ...
pm2 start ${TOMOCHAIN_DIR}/build/bin/bootnode --name bootnode -- -nodekey ./bootnode.key
echo Starting the nodes ...
pm2 start ${TOMOCHAIN_DIR}/build/bin/tomo --name sun -- \
--bootnodes "${BOOTNODES}" --syncmode "full" \
--tomo-testnet \
--datadir ./nodes/1 --networkid ${NETWORKID} --port 30303 \
--tomox --tomox.datadir "$WORK_DIR/nodes/1/tomox" --tomox.dbengine "leveldb" \
--announce-txs \
--store-reward \
--gcmode "archive" \
--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 8545 --rpcvhosts "*" \
--rpcapi "personal,db,eth,net,web3,txpool,tomox,debug,posv" \
--ws --wsaddr 0.0.0.0 --wsport 8546 --wsorigins "*" --unlock "${wallet1}" \
--ethstats "sun:${WS_SECRET}@localhost:3004" \
--password ./.pwd --mine --gasprice "${GASPRICE}" --targetgaslimit "420000000" --verbosity 4
pm2 start ${TOMOCHAIN_DIR}/build/bin/tomo --name moon -- \
--bootnodes "${BOOTNODES}" --syncmode "full" \
--tomo-testnet \
--datadir ./nodes/2 --networkid ${NETWORKID} --port 30304 \
--tomox --tomox.datadir "$WORK_DIR/nodes/2/tomox" --tomox.dbengine "leveldb" \
--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 8501 --rpcvhosts "*" \
--rpcapi "personal,db,eth,net,web3,txpool,tomox,posv" \
--unlock "${wallet2}" --password ./.pwd --mine --gasprice "${GASPRICE}" --targetgaslimit "420000000" \
--ethstats "moon:${WS_SECRET}@localhost:3004" \
--verbosity ${VERBOSITY}
pm2 start ${TOMOCHAIN_DIR}/build/bin/tomo --name earth -- \
--bootnodes "${BOOTNODES}" \
--tomo-testnet \
--syncmode "full" --datadir ./nodes/3 --networkid ${NETWORKID} --port 30305 \
--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 8548 --rpcvhosts "*" \
--tomox --tomox.datadir "$WORK_DIR/nodes/3/tomox" --tomox.dbengine "leveldb" \
--unlock "${wallet3}" --password ./.pwd --mine --gasprice "${GASPRICE}" \
--ethstats "earth:${WS_SECRET}@localhost:3004" \
--targetgaslimit "420000000" --verbosity ${VERBOSITY}
pm2 start ${TOMOCHAIN_DIR}/build/bin/tomo --name tomox-fullnode -- \
--bootnodes "${BOOTNODES}" \
--tomo-testnet \
--syncmode "full" --datadir ./nodes/7 --networkid ${NETWORKID} --port 30309 \
--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 8552 --rpcvhosts "*" \
--announce-txs \
--ws --wsaddr 0.0.0.0 --wsport 8553 --wsorigins "*" --unlock "${wallet7}" \
--rpcapi "personal,db,eth,net,web3,txpool,tomox,debug,posv" \
--tomox --tomox.datadir "$WORK_DIR/nodes/7/tomox" --tomox.dbengine "mongodb" \
--password ./.pwd --mine --gasprice "${GASPRICE}" \
--ethstats "fullnode:${WS_SECRET}@localhost:3004" \
--targetgaslimit "420000000" --verbosity 4
echo Building tomowallet ...
cd ${WALLET_DIR} && npm run build:prod && cp privacy.wasm dist/dev/
echo Starting tomoscan ...
cd ${SCAN_DIR}/client && pm2 start npm --name tomoscan-client -- run start
cd ${SCAN_DIR}/server && pm2 start npm --name tomoscan-server -- run start
cd ${SCAN_DIR}/server && pm2 start npm --name tomoscan-producer -- run producer
cd ${SCAN_DIR}/server && pm2 start npm --name tomoscan-crawler -- run crawl -i max
cd ${SCAN_DIR}/server && pm2 start npm --name tomoscan-trade-process -- run tradeProcess
echo Starting faucet ...
cd ${FAUCET_DIR} && PORT=3007 pm2 start index.js --name faucet
echo Starting tomomaster ...
cd ${MASTER_DIR} && pm2 start npm --name tomomaster -- run start
cd ${MASTER_DIR} && pm2 start npm --name tomomaster-cralwer -- run crawl
if $ISRESET
then
# echo Run the graph node...
# cd /root/uniswap/ && pm2 start --name graph-node ./graph-node -- --postgres-url postgresql://graph:123456@localhost:5432/graph --ethereum-rpc tomochain_devnet:http://localhost:8545 --ipfs 127.0.0.1:5001 --debug
#
echo Deploy TRC21, sleep 20 seconds ...
sleep 20
cd ${TOMOCHAIN_DIR}/contracts/tomox/testnet/deploy && go run main.go
echo Deploy Privacy Contracts, sleep 10 seconds ...
sleep 10
cd ${PRIVACY_SC_DIR} && truffle deploy --network testnet
sleep 10
cd ${PRIVACYJS_DIR} && npm run testcase deposit
echo Deploy Swap Contracts, sleep 10 seconds ...
sleep 10
cd ${HOME}/toniswap-core && node deploy.js && cd ${HOME}/toniswap-periphery && node deploy.js
# cd /root/uniswap/ethereum-blocks && npm run create-local && npm run deploy-local
# cd /root/uniswap/toniswap-subgraph && npm run create-local && npm run deploy-local
#
fi
echo Sleep 20 seconds ...
sleep 20
echo Starting tomox-sdk ...
cd ${TOMOXSDK_DIR} && pm2 start ./tomox-sdk --name tomox-sdk
#
#echo Starting tomorelayer ...
#cd ${TOMORELAYER_DIR} && ENV_PATH=.env.local pipenv run pm2 start --name tomorelayer python -- ./backend/app.py
#cd ${TOMORELAYER_DIR} && ENV_PATH=.env.local pipenv run pm2 start --name tomorelayer-cron python -- ./backend/cron.py
#
#echo Starting toniswap ...
#cd /root/uniswap/toniswap-interface && PORT=3009 pm2 start --name toniswap npm -- start
#
echo Sleep 30 seconds ...
sleep 30
echo Starting bot ...
cd ${BOT_DIR} && pm2 start cmd.js --name TOMOBTC -- bot TOMO-BTC
cd ${BOT_DIR} && pm2 start cmd.js --name ETHTOMO -- bot ETH-TOMO
cd ${BOT_DIR} && pm2 start cmd.js --name ETHBTC -- bot ETH-BTC
cd ${BOT_DIR} && pm2 start cmd.js --name BTCUSD -- bot BTC-USD
cd ${BOT_DIR} && pm2 start cmd.js --name ETHUSD -- bot ETH-USD
cd ${BOT_DIR} && pm2 start cmd.js --name TOMOUSD -- bot TOMO-USD
#cd ${BOT_DIR} && pm2 start cmd.js --name USD60 -- lend USD-60
#cd ${BOT_DIR} && pm2 start cmd.js --name USD86400 -- lend USD-86400
#cd ${BOT_DIR} && pm2 start cmd.js --name USD604800 -- lend USD-604800
#cd ${BOT_DIR} && pm2 start cmd.js --name USD2592000 -- lend USD-2592000
#cd ${BOT_DIR} && pm2 start cmd.js --name BTC86400 -- lend BTC-86400
#cd ${BOT_DIR} && pm2 start cmd.js --name TOMO86400 -- lend TOMO-86400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment