|
| 1 | +#!/usr/bin/env zsh |
| 2 | +# chmod +x ./start_infrablockchain_testnet_node_local.sh |
| 3 | + |
| 4 | +setopt shwordsplit |
| 5 | + |
| 6 | +export INFRA_NODE_BIN_NAME=infra-node |
| 7 | +export INFRA_CLI_BIN_NAME=infra-cli |
| 8 | +export INFRA_KEYCHAIN_BIN_NAME=infra-keychain |
| 9 | + |
| 10 | +export INFRABLOCKCHAIN_HOME=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain-2-git |
| 11 | + |
| 12 | +export INFRA_NODE=$INFRABLOCKCHAIN_HOME/build/bin/$INFRA_NODE_BIN_NAME |
| 13 | +export INFRA_NODE_LOG_FILE=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain_local_testnet_data/log/$INFRA_NODE_BIN_NAME.log |
| 14 | + |
| 15 | +export INFRA_CLI=($INFRABLOCKCHAIN_HOME/build/bin/$INFRA_CLI_BIN_NAME --wallet-url http://127.0.0.1:8900/) |
| 16 | +export INFRA_KEYCHAIN=$INFRABLOCKCHAIN_HOME/build/bin/$INFRA_KEYCHAIN_BIN_NAME |
| 17 | +export INFRA_KEYCHAIN_LOG_FILE=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain_local_testnet_data/log/$INFRA_KEYCHAIN_BIN_NAME.log |
| 18 | +export INFRABLOCKCHAIN_DEV_WALLET_DIR=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain_local_testnet_data/infrablockchain_dev_wallet |
| 19 | +export INFRA_KEYCHAIN_WALLET_PASSWORD=PW5JcN2AfwXxAV12W1mofb7pbeyJEwwie4JsCaTZvMx5kt38P8TP1 |
| 20 | +export INFRA_KEYCHAIN_WALLET_NAME=local-testnet |
| 21 | + |
| 22 | +export INFRA_NODE_CONFIG=$INFRABLOCKCHAIN_HOME/infrablockchain-bios/config/config_infrablockchain_local_testnet.ini |
| 23 | +export INFRA_NODE_GENESIS_JSON=$INFRABLOCKCHAIN_HOME/infrablockchain-bios/config/genesis_infrablockchain_local_testnet.json |
| 24 | +export INFRA_NODE_DATA_DIR=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain_local_testnet_data/infra_node_data |
| 25 | + |
| 26 | +export INFRABLOCKCHAIN_CONTRACTS_DIR=/Users/bwlim/Documents/__InfraBlockchain__/infrablockchain.contracts-git/build/contracts |
| 27 | + |
| 28 | +export SYS_ACCOUNT=eosio |
| 29 | + |
| 30 | +export INFRA_NODE_API_ENDPOINT=http://127.0.0.1:8888 |
| 31 | + |
| 32 | +{ set +x; } 2>/dev/null |
| 33 | +red=`tput setaf 1` |
| 34 | +green=`tput setaf 2` |
| 35 | +magenta=`tput setaf 6` |
| 36 | +reset=`tput sgr0` |
| 37 | +set -x |
| 38 | + |
| 39 | +{ set +x; } 2>/dev/null |
| 40 | +echo "${red}[(Re)Starting INFRABLOCKCHAIN Local Testnet]${reset}" |
| 41 | +echo |
| 42 | +echo "${green}INFRABLOCKCHAIN_HOME${reset}=${red}$INFRABLOCKCHAIN_HOME${reset}" |
| 43 | +echo "${green}INFRA_NODE${reset}=${red}$INFRA_NODE${reset}" |
| 44 | +echo "${green}INFRA_NODE_LOG_FILE${reset}=${red}$INFRA_NODE_LOG_FILE${reset}" |
| 45 | +echo "${green}INFRA_CLI${reset}=${red}$INFRA_CLI${reset}" |
| 46 | +echo "${green}INFRA_CLI_TESTNET${reset}=${red}$INFRA_CLI_TESTNET${reset}" |
| 47 | +echo "${green}INFRA_KEYCHAIN${reset}=${red}$INFRA_KEYCHAIN${reset}" |
| 48 | +echo "${green}INFRA_KEYCHAIN_LOG_FILE${reset}=${red}$INFRA_KEYCHAIN_LOG_FILE${reset}" |
| 49 | +echo "${green}INFRA_KEYCHAIN_WALLET_PASSWORD${reset}=${red}$INFRA_KEYCHAIN_WALLET_PASSWORD${reset}" |
| 50 | +echo "${green}INFRA_NODE_CONFIG${reset}=${red}$INFRA_NODE_CONFIG${reset}" |
| 51 | +echo "${green}INFRA_NODE_GENESIS_JSON${reset}=${red}$INFRA_NODE_GENESIS_JSON${reset}" |
| 52 | +echo "${green}INFRA_NODE_DATA_DIR${reset}=${red}$INFRA_NODE_DATA_DIR${reset}" |
| 53 | +echo "${green}INFRABLOCKCHAIN_DEV_WALLET_DIR${reset}=${red}$INFRABLOCKCHAIN_DEV_WALLET_DIR${reset}" |
| 54 | +echo "${green}INFRABLOCKCHAIN_CONTRACTS_DIR${reset}=${red}$INFRABLOCKCHAIN_CONTRACTS_DIR${reset}" |
| 55 | +echo "${green}SYS_ACCOUNT${reset}=${red}$SYS_ACCOUNT${reset}" |
| 56 | +echo "${green}INFRA_NODE_API_ENDPOINT${reset}=${red}INFRA_NODE_API_ENDPOINT${reset}" |
| 57 | +echo |
| 58 | +set -x |
| 59 | + |
| 60 | +{ set +x; } 2>/dev/null |
| 61 | +echo "${red}Ready to (re)start InfraBlockchain Testnet node?${reset}" |
| 62 | +echo "write YES to proceed stop process." |
| 63 | +read USER_CONFIRM_TO_PROCEED |
| 64 | +if [ "$USER_CONFIRM_TO_PROCEED" != "YES" ]; then |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | +set -x |
| 68 | + |
| 69 | +print_section_title() { |
| 70 | + { set +x; } 2>/dev/null |
| 71 | + echo |
| 72 | + echo "${green}[$1]${reset}" |
| 73 | + echo |
| 74 | + set -x |
| 75 | +} |
| 76 | + |
| 77 | +{ print_section_title "Stop infra-node"; } 2>/dev/null |
| 78 | + |
| 79 | +pgrep $INFRA_NODE_BIN_NAME |
| 80 | +pkill -SIGINT $INFRA_NODE_BIN_NAME |
| 81 | +sleep 2 |
| 82 | +tail $INFRA_NODE_LOG_FILE |
| 83 | + |
| 84 | + |
| 85 | +{ print_section_title "Stop key daemon"; } 2>/dev/null |
| 86 | + |
| 87 | +pgrep $INFRA_KEYCHAIN_BIN_NAME |
| 88 | +pkill -SIGINT $INFRA_KEYCHAIN_BIN_NAME |
| 89 | +sleep 5 |
| 90 | +tail $INFRA_KEYCHAIN_LOG_FILE |
| 91 | + |
| 92 | + |
| 93 | +{ print_section_title "Start key daemon"; } 2>/dev/null |
| 94 | + |
| 95 | +nohup $INFRA_KEYCHAIN --unlock-timeout 999999999 --http-server-address 127.0.0.1:8900 --wallet-dir $INFRABLOCKCHAIN_DEV_WALLET_DIR > $INFRA_KEYCHAIN_LOG_FILE 2>&1& |
| 96 | +sleep 2 |
| 97 | +$INFRA_CLI wallet open |
| 98 | +$INFRA_CLI wallet unlock --password $INFRA_KEYCHAIN_WALLET_PASSWORD |
| 99 | +tail $INFRA_KEYCHAIN_LOG_FILE |
| 100 | + |
| 101 | +{ print_section_title "Start infra-node"; } 2>/dev/null |
| 102 | + |
| 103 | +nohup $INFRA_NODE --config $INFRA_NODE_CONFIG --data-dir $INFRA_NODE_DATA_DIR --disable-replay-opts > $INFRA_NODE_LOG_FILE 2>&1& |
| 104 | +sleep 10 |
| 105 | +tail $INFRA_NODE_LOG_FILE |
| 106 | + |
| 107 | +{ set +x; } 2>/dev/null |
0 commit comments