go-ethereum/scripts/getconfig.sh
SHIVAM SHARMA 9aeaf03f05
Merge branch 'qa' and 'master' into develop (#663)
* Adding in Mumbai/Mainnet precursor deb packaging for tests to use during upgrade(iterations to come)

* Added changes per discussion in PR, more changes may be necessary

* Adding prerelease true

* Disabling goreleaser

* Removing README swap file

* change bor_dir and add bor user for v0.3.0 release

* rollback bor user and use root

* metrics: handle equal to separated config flag (#596)

* metrics: handle  based config path

* internal/cli/server: add more context to logs

* use space separated flag and value in bor.service

* fixed static-nodes related buf (os independent) (#598)

* fixed static-nodes related buf (os independent)

* taking static-nodes as input if default not present

* Update default flags (#600)

* internal/cli/server: use geth's default for txpool.pricelimit and add comments

* builder/files: update config.toml for mainnet

* packaging/templates: update defaults for mainnet and mumbai

* internal/cli/server: skip overriding cache

* packaging/templates: update cache value for mainnet

* packaging/templates: update gcmode for archive mumbai node

* metrics: handle nil telemetry config (#601)

* resolve merge conflicts

* update go version in release.yml

* update goversion in makefile

* update Docker login for goreleaser-cross v1.19

* Cleanup for the packager to use git tag in the package profile naming. Added conditional check for directory structure, this is in prep for v0.3.1, as this will create a failure on upgrade path in package due to file exist

* added a toml configuration file with comments describing each flag (#607)

* added a toml configuration file with comments describing each flag

* internal/cli/server: update flag description

* docs/cli: update example config and description of flags

* docs: update new-cli docs

Co-authored-by: Manav Darji <manavdarji.india@gmail.com>

* Adding of 0.3.0 package changes, control file updates, postinst changes, and packager update

* added ancient datadir flag and toml field, need to decide on default value and update the conversion script

* updated toml files with ancient field

* Add support for new flags in new config.toml, which were present in old config.toml (#612)

* added HTTPTimeouts, and TrieTimeout flag in new tol, from old toml

* added RAW fields for these time.Duration flags

* updated the conversion script to support these extra 4 flags

* removed hcl and json config tests as we are only supporting toml config files

* updated toml files with cache.timeout field

* updated toml files with jsonrpc.timeouts field

* tests/bor: expect a call for latest checkpoint

* tests/bor: expect a call for latest checkpoint

* packaging/templates: update cache values for archive nodes

Co-authored-by: Manav Darji <manavdarji.india@gmail.com>

* remove unwanted code

* Fix docker publish authentication issue

In gorelease-cross 1.19+, dockerhub authentication will require docker
logion action followed by mounting docker config file. See
https://github.com/goreleaser/goreleaser-cross#github-actions.

* Revert "update Docker login for goreleaser-cross v1.19"

This reverts commit 4d19cf5342.

* Bump version to stable

* Revert "Merge pull request #435 from maticnetwork/POS-553"

This reverts commit 657d262def, reversing
changes made to 88dbfa1c13.

* revert change for release for go1.19

* Add default values to CLI helper and docs

This commit adds default values to CLI helper and docs. When the default value of a string flag, slice string flag, or map string flag is empty, its helper message won't show any default value.

* Add a summary of new CLI in docs

* Updating packager as binutils changed version so that apt-get installs current versions

* Add state pruning to new CLI

* Minor wording fix in prune state description

* Bumping control file versions

* Mainnet Delhi fork

* Set version to stable

* change delhi hardfork block number

* handle future chain import and skip peer drop (#650)

* handle future chain import and skip peer drop

* add block import metric

* params: bump version to v0.3.3-stable

* Bump bor version in control files for v0.3.3 mainnet release

Co-authored-by: Daniel Jones <djones@polygon.technology>
Co-authored-by: Will Button <wbutton@polygon.technology>
Co-authored-by: Will Button <will@willbutton.com>
Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
Co-authored-by: Daniel Jones <105369507+djpolygon@users.noreply.github.com>
Co-authored-by: Pratik Patil <pratikspatil024@gmail.com>
Co-authored-by: Arpit Temani <temaniarpit27@gmail.com>
Co-authored-by: Jerry <jerrycgh@gmail.com>
2023-01-13 14:47:14 +05:30

177 lines
5.8 KiB
Bash
Executable file

#!/bin/bash
set -e
# Instructions:
# Execute `./getconfig.sh`, and follow the instructions displayed on the terminal
# The `*-config.toml` file will be created in the same directory as start.sh
# It is recommended to check the flags generated in config.toml
# Some checks to make commands OS independent
OS="$(uname -s)"
MKTEMPOPTION=
SEDOPTION= ## Not used as of now (TODO)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
SEDOPTION="''"
MKTEMPOPTION="-t"
fi
read -p "* Path to start.sh: " startPath
# check if start.sh is present
if [[ ! -f $startPath ]]
then
echo "Error: start.sh do not exist."
exit 1
fi
read -p "* Your validator address (e.g. 0xca67a8D767e45056DC92384b488E9Af654d78DE2), or press Enter to skip if running a sentry node: " ADD
if [[ -f $HOME/.bor/data/bor/static-nodes.json ]]
then
cp $HOME/.bor/data/bor/static-nodes.json ./static-nodes.json
else
read -p "* You dont have '~/.bor/data/bor/static-nodes.json' file. If you want to use static nodes, enter the path to 'static-nodes.json' here (press Enter to skip): " STAT
if [[ -f $STAT ]]; then cp $STAT ./static-nodes.json; fi
fi
printf "\nThank you, your inputs are:\n"
echo "Path to start.sh: "$startPath
echo "Address: "$ADD
confPath=${startPath%.sh}"-config.toml"
echo "Path to the config file: "$confPath
# check if config.toml is present
if [[ -f $confPath ]]
then
echo "WARN: config.toml exists, data will be overwritten."
fi
printf "\n"
tmpDir="$(mktemp -d $MKTEMPOPTION ./temp-dir-XXXXXXXXXXX || oops "Can't create temporary directory")"
cleanup() {
rm -rf "$tmpDir"
}
trap cleanup EXIT INT QUIT TERM
# SHA1 hash of `tempStart` -> `3305fe263dd4a999d58f96deb064e21bb70123d9`
sed 's/bor --/go run getconfig.go notYet --/g' $startPath > $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
chmod +x $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
$tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh $ADD
rm $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%*%'*'%g" ./temp
else
sed -i "s%*%'*'%g" ./temp
fi
# read the flags from `./temp`
dumpconfigflags=$(head -1 ./temp)
# run the dumpconfig command with the flags from `./temp`
command="bor dumpconfig "$dumpconfigflags" > "$confPath
bash -c "$command"
rm ./temp
printf "\n"
if [[ -f ./tempStaticNodes.json ]]
then
echo "JSON StaticNodes found"
staticnodesjson=$(head -1 ./tempStaticNodes.json)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodesjson}\"\]%" $confPath
else
sed -i "s%static-nodes = \[\]%static-nodes = \[\"${staticnodesjson}\"\]%" $confPath
fi
rm ./tempStaticNodes.json
elif [[ -f ./tempStaticNodes.toml ]]
then
echo "TOML StaticNodes found"
staticnodestoml=$(head -1 ./tempStaticNodes.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodestoml}\"\]%" $confPath
else
sed -i "s%static-nodes = \[\]%static-nodes = \[\"${staticnodestoml}\"\]%" $confPath
fi
rm ./tempStaticNodes.toml
else
echo "neither JSON nor TOML StaticNodes found"
fi
if [[ -f ./tempTrustedNodes.toml ]]
then
echo "TOML TrustedNodes found"
trustednodestoml=$(head -1 ./tempTrustedNodes.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%trusted-nodes = \[\]%trusted-nodes = \[\"${trustednodestoml}\"\]%" $confPath
else
sed -i "s%trusted-nodes = \[\]%trusted-nodes = \[\"${trustednodestoml}\"\]%" $confPath
fi
rm ./tempTrustedNodes.toml
else
echo "neither JSON nor TOML TrustedNodes found"
fi
if [[ -f ./tempHTTPTimeoutsReadTimeout.toml ]]
then
echo "HTTPTimeouts.ReadTimeout found"
read=$(head -1 ./tempHTTPTimeoutsReadTimeout.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%read = \"30s\"%read = \"${read}\"%" $confPath
else
sed -i "s%read = \"30s\"%read = \"${read}\"%" $confPath
fi
rm ./tempHTTPTimeoutsReadTimeout.toml
fi
if [[ -f ./tempHTTPTimeoutsWriteTimeout.toml ]]
then
echo "HTTPTimeouts.WriteTimeout found"
write=$(head -1 ./tempHTTPTimeoutsWriteTimeout.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%write = \"30s\"%write = \"${write}\"%" $confPath
else
sed -i "s%write = \"30s\"%write = \"${write}\"%" $confPath
fi
rm ./tempHTTPTimeoutsWriteTimeout.toml
fi
if [[ -f ./tempHTTPTimeoutsIdleTimeout.toml ]]
then
echo "HTTPTimeouts.IdleTimeout found"
idle=$(head -1 ./tempHTTPTimeoutsIdleTimeout.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%idle = \"2m0s\"%idle = \"${idle}\"%" $confPath
else
sed -i "s%idle = \"2m0s\"%idle = \"${idle}\"%" $confPath
fi
rm ./tempHTTPTimeoutsIdleTimeout.toml
fi
if [[ -f ./tempHTTPTimeoutsTrieTimeout.toml ]]
then
echo "Eth.TrieTimeout found"
timeout=$(head -1 ./tempHTTPTimeoutsTrieTimeout.toml)
shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then
sed -i '' "s%timeout = \"1h0m0s\"%timeout = \"${timeout}\"%" $confPath
else
sed -i "s%timeout = \"1h0m0s\"%timeout = \"${timeout}\"%" $confPath
fi
rm ./tempHTTPTimeoutsTrieTimeout.toml
fi
printf "\n"
# comment flags in $configPath that were not passed through $startPath
# SHA1 hash of `tempStart` -> `3305fe263dd4a999d58f96deb064e21bb70123d9`
sed "s%bor --%go run getconfig.go ${confPath} --%" $startPath > $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
chmod +x $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
$tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh $ADD
rm $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh
if [[ -f $HOME/.bor/data/bor/static-nodes.json ]]
then
rm ./static-nodes.json
fi
exit 0