From 8fd5461c73e2ab800db933fed22f432c3126438e Mon Sep 17 00:00:00 2001 From: dongsam Date: Thu, 21 Oct 2021 18:26:40 +0900 Subject: [PATCH 1/2] docs: add -i options for sed considering os --- docs/Tutorials/localnet/README.md | 18 ++++++++++++------ scripts/localnet.sh | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/Tutorials/localnet/README.md b/docs/Tutorials/localnet/README.md index 80296fb..33c5266 100644 --- a/docs/Tutorials/localnet/README.md +++ b/docs/Tutorials/localnet/README.md @@ -38,15 +38,21 @@ $BINARY add-genesis-account $($BINARY keys show user2 --keyring-backend test -a) $BINARY gentx val1 100000000stake --chain-id $CHAIN_ID --keyring-backend test $BINARY collect-gentxs +# Check OS for sed -i option value +export SED_I="" +if [[ "$OSTYPE" == "darwin"* ]]; then + export SED_I="''" +fi + # Modify app.toml -sed -i '' 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml -sed -i '' 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml +sed -i $SED_I 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml +sed -i $SED_I 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml # Modify parameters for the governance proposal -sed -i '' 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json -sed -i '' 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json -sed -i '' 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json -sed -i '' 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json +sed -i $SED_I 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json +sed -i $SED_I 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json +sed -i $SED_I 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json +sed -i $SED_I 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json # Start $BINARY start diff --git a/scripts/localnet.sh b/scripts/localnet.sh index 45187d2..80affa2 100755 --- a/scripts/localnet.sh +++ b/scripts/localnet.sh @@ -40,13 +40,19 @@ echo "Creating and collecting gentx..." $BINARY gentx validator 1000000000stake --home $CHAIN_DIR/$CHAIN_ID --chain-id $CHAIN_ID --keyring-backend test $BINARY collect-gentxs --home $CHAIN_DIR/$CHAIN_ID +# Check OS for sed -i option value +export SED_I="" +if [[ "$OSTYPE" == "darwin"* ]]; then + export SED_I="''" +fi + echo "Change settings in config.toml file..." -sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPC_PORT"'"#g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i '' 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml -sed -i '' 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml +sed -i $SED_I 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPC_PORT"'"#g' $CHAIN_DIR/$CHAIN_ID/config/config.toml +sed -i $SED_I 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml +sed -i $SED_I 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml +sed -i $SED_I 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml +sed -i $SED_I 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml +sed -i $SED_I 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml echo "Starting $CHAIN_ID in $CHAIN_DIR..." echo "Log file is located at $CHAIN_DIR/$CHAIN_ID.log" From 4cd02b20a4276cd68cadc6e4eea78a3765c25dde Mon Sep 17 00:00:00 2001 From: dongsam Date: Mon, 1 Nov 2021 10:20:31 +0900 Subject: [PATCH 2/2] docs: apply suggestions for macos --- docs/Tutorials/localnet/README.md | 37 ++++++++++++++++++------------- scripts/localnet.sh | 30 ++++++++++++++++--------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/docs/Tutorials/localnet/README.md b/docs/Tutorials/localnet/README.md index 33c5266..87abfca 100644 --- a/docs/Tutorials/localnet/README.md +++ b/docs/Tutorials/localnet/README.md @@ -38,21 +38,28 @@ $BINARY add-genesis-account $($BINARY keys show user2 --keyring-backend test -a) $BINARY gentx val1 100000000stake --chain-id $CHAIN_ID --keyring-backend test $BINARY collect-gentxs -# Check OS for sed -i option value -export SED_I="" -if [[ "$OSTYPE" == "darwin"* ]]; then - export SED_I="''" -fi - -# Modify app.toml -sed -i $SED_I 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml -sed -i $SED_I 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml - -# Modify parameters for the governance proposal -sed -i $SED_I 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json -sed -i $SED_I 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json -sed -i $SED_I 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json -sed -i $SED_I 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json +# Check platform +platform='unknown' +unamestr=`uname` +if [ "$unamestr" = 'Linux' ]; then + platform='linux' +fi + +if [ $platform = 'linux' ]; then + sed -i 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml + sed -i 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml + sed -i 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json + sed -i 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json + sed -i 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json + sed -i 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json +else + sed -i '' 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml + sed -i '' 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml + sed -i '' 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json + sed -i '' 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json + sed -i '' 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json + sed -i '' 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json +fi # Start $BINARY start diff --git a/scripts/localnet.sh b/scripts/localnet.sh index 80affa2..6213ce1 100755 --- a/scripts/localnet.sh +++ b/scripts/localnet.sh @@ -40,19 +40,29 @@ echo "Creating and collecting gentx..." $BINARY gentx validator 1000000000stake --home $CHAIN_DIR/$CHAIN_ID --chain-id $CHAIN_ID --keyring-backend test $BINARY collect-gentxs --home $CHAIN_DIR/$CHAIN_ID -# Check OS for sed -i option value -export SED_I="" -if [[ "$OSTYPE" == "darwin"* ]]; then - export SED_I="''" +# Check platform +platform='unknown' +unamestr=`uname` +if [ "$unamestr" = 'Linux' ]; then + platform='linux' fi echo "Change settings in config.toml file..." -sed -i $SED_I 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPC_PORT"'"#g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i $SED_I 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i $SED_I 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i $SED_I 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml -sed -i $SED_I 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml -sed -i $SED_I 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml +if [ $platform = 'linux' ]; then + sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPC_PORT"'"#g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml + sed -i 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml +else + sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPC_PORT"'"#g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml + sed -i '' 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml + sed -i '' 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAIN_ID/config/app.toml +fi echo "Starting $CHAIN_ID in $CHAIN_DIR..." echo "Log file is located at $CHAIN_DIR/$CHAIN_ID.log"