cic-staff-installer/setup_evm.sh

81 lines
3.0 KiB
Bash
Raw Normal View History

2022-01-27 10:25:17 +01:00
. aux/bdbg/bdbg.sh
. setup_path.sh
# set -o xtrace
GIT_OPENETHEREUM=${GIT_OPENETHEREUM:-https://github.com/openethereum/openethereum}
default_openethereum_chain="kitabu" # bloxberg | kitabu
export OPENETHEREUM_CHAIN=${INSTALL_EVM:-$default_openethereum_chain}
OPENETHEREUM_PATH=${OPENETHEREUM_PATH:-$HOME/.local/bin/parity}
openethereum_dir=`realpath $(dirname $OPENETHEREUM_PATH)`
default_openethereum_run=$HOME/.local/share/io.parity.ethereum/$OPENETHEREUM_CHAIN
default_openethereum_config=$HOME/.config/io.parity.ethereum/$OPENETHEREUM_CHAIN
export OPENETHEREUM_RUN=${OPENETHEREUM_RUN:-$default_openethereum_run}
export OPENETHEREUM_CONFIG=${OPENETHEREUM_CONFIG:-$default_openethereum_config}
default_openethereum_type="binary" # source | binary
export OPENETHEREUM_TYPE=${OPENETHEREUM_TYPE:-$default_openethereum_type}
download_openethereum() {
openethereum_version="3.3.3"
if [ ! -f "$PWD/openethereum-linux-v$openethereum_version.zip" ]; then
wget https://github.com/openethereum/openethereum/releases/download/v$openethereum_version/openethereum-linux-v$openethereum_version.zip
fi
unzip openethereum-linux-v$openethereum_version.zip
rm openethereum-linux-v$openethereum_version.zip
./openethereum --version
mv ./openethereum $openethereum_dir/parity
export OPENETHEREUM_PATH=$openethereum_dir/parity
}
build_openethereum() {
dbg $dbg_debug "downloading bloxberg node"
t=`mktemp -d`
pushd $t
install_env=1
git clone $GIT_OPENETHEREUM
cd openethereum
git checkout 2662d1925ec794f3ad7c5759b2412ff5128d259b
rustup install 1.47.0
cargo build --release --features final
cp -v $t/target/release/parity $openethereum_dir
export OPENETHEREUM_PATH=$openethereum_dir/parity
}
install_env=
if [ ! -f $OPENETHEREUM_PATH ]; then
# Download and Build parity from git $GIT_OPENETHEREUM
if [ "$OPENETHEREUM_TYPE" = "source" ]; then
build_openethereum
else
download_openethereum
fi
else
dbg $dbg_info "found bloxberg node executable in $OPENETHEREUM_PATH"
fi
#OPENETHEREUM_RUN=~/.local/share/io.parity.ethereum/$OPENETHEREUM_CHAIN
if [ ! -d $OPENETHEREUM_RUN ]; then
mkdir -vp $OPENETHEREUM_RUN/bootnode
mkdir -vp $OPENETHEREUM_CONFIG
touch $OPENETHEREUM_CONFIG/bootnode.pwd
dd status=xfer if=/dev/urandom bs=32 count=1 2> /dev/null | hexdump -v -n 32 -e '1/1 "%02x"' > $OPENETHEREUM_CONFIG/bootnode.pwd
chmod -v 400 $OPENETHEREUM_CONFIG/bootnode.pwd
./aux/bash-templater/templater.sh var/$OPENETHEREUM_CHAIN/bootnode.toml > $OPENETHEREUM_CONFIG/bootnode.toml
cp -v var/$OPENETHEREUM_CHAIN/$OPENETHEREUM_CHAIN.json $OPENETHEREUM_CONFIG/
if [ -f var/$OPENETHEREUM_CHAIN/bootnodes.txt ] ; then
cp -v var/$OPENETHEREUM_CHAIN/bootnodes.txt $OPENETHEREUM_CONFIG/
fi
./aux/bash-templater/templater.sh systemd/node.service > $HOME/.config/systemd/user/$OPENETHEREUM_CHAIN.service
./aux/bash-templater/templater.sh systemd/env/01-$OPENETHEREUM_CHAIN.conf > $HOME/.config/environment.d/01-$OPENETHEREUM_CHAIN.conf
systemctl --user daemon-reload
else
echo Found $OPENETHEREUM_RUN directory! Skipping
fi
update_path $openethereum_dir
if [ ! -z "$install_env" ]; then
popd
fi