#!/bin/bash
chmod +x /interface_setup
/interface_setup
ip rou del default 2> /dev/null
ip route add default via 10.151.0.254 dev net0
[ ! -e "/root/.ethereum/geth/nodekey" ] && geth --datadir /root/.ethereum init /tmp/eth-genesis.json
cp /tmp/keystore/UTC--2023-03-02T12-56-17.261309000Z--0xD4CC43e3f2830f9082495Dba904B57fc2Ca95CBd /root/.ethereum/keystore/
cp /tmp/keystore/UTC--2023-03-02T12-56-45.058858000Z--0x5551Ee6a5E1c07A91B8a8F0Ec795d664b6F5F984 /root/.ethereum/keystore/
chmod +x /tmp/eth-bootstrapper
/tmp/eth-bootstrapper
geth --datadir /root/.ethereum --identity="NODE_4" --networkid=1337 --syncmode full --snapshot=False --verbosity=2 --allow-insecure-unlock --port 30303 --bootnodes "$(cat /tmp/eth-node-urls)" --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --http.api web3,eth,debug,personal,net,clique,engine,admin,txpool --unlock "0xD4CC43e3f2830f9082495Dba904B57fc2Ca95CBd, 0x5551Ee6a5E1c07A91B8a8F0Ec795d664b6F5F984" --password "/tmp/eth-password"                             --miner.etherbase "0xD4CC43e3f2830f9082495Dba904B57fc2Ca95CBd" --mine --miner.threads=1 &

echo "ready! run 'docker exec -it $HOSTNAME /bin/zsh' to attach to this node" >&2
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > "$f"; done
tail -f /dev/null

