initial 0g
This commit is contained in:
15
0g/0g.Dockerfile
Normal file
15
0g/0g.Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
FROM ubuntu:21.10
|
||||||
|
|
||||||
|
COPY ./scripts/init.sh /usr/local/bin/init.sh
|
||||||
|
RUN chmod +x /usr/local/bin/init.sh
|
||||||
|
|
||||||
|
RUN apt update && apt install -y curl tar gzip
|
||||||
|
|
||||||
|
ARG 0G_VERSION
|
||||||
|
ARG ${0G_CHAIN_SPEC:-galileo}
|
||||||
|
RUN curl -sL https://github.com/0glabs/0gchain-NG/releases/download/v${0G_VERSION}/${0G_CHAIN_SPEC}-v${0G_VERSION}.tar.gz -o /tmp/${0G_CHAIN_SPEC}-v${0G_VERSION}.tar.gz
|
||||||
|
RUN tar -xzf /tmp/${0G_CHAIN_SPEC}-v${0G_VERSION}.tar.gz -C /tmp
|
||||||
|
RUN mv /tmp/${0G_CHAIN_SPEC}-v${0G_VERSION} /0g
|
||||||
|
|
||||||
|
ENTRYPOINT [ "init.sh" ]
|
||||||
59
0g/scripts/init.sh
Normal file
59
0g/scripts/init.sh
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e # Exit on failure
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Error: No argument provided. Please specify '0gchaind' or 'geth' as the first argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MODE="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$MODE" in
|
||||||
|
0gchaind)
|
||||||
|
# Continue with 0gchaind-specific logic (rest of script)
|
||||||
|
;;
|
||||||
|
geth)
|
||||||
|
GETH_DATA_DIR="/root/.ethereum/"
|
||||||
|
|
||||||
|
if [ ! -f "$GETH_DATA_DIR/initialized" ]; then
|
||||||
|
/0g/bin/geth init --datadir $GETH_DATA_DIR /0g/genesis.json
|
||||||
|
touch "$GETH_DATA_DIR/initialized"
|
||||||
|
else
|
||||||
|
echo "Already initialized, continuing!" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /0g/bin/geth $@
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown argument '$MODE'. Please specify '0gchaind' or 'geth'."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "MONIKER: $MONIKER"
|
||||||
|
|
||||||
|
AUTH_RPC=${AUTH_RPC:-http://0g-$CHAIN_NAME:8551} # just as example
|
||||||
|
|
||||||
|
HOME_DIR="/root/.0g"
|
||||||
|
mkdir -p $HOME_DIR
|
||||||
|
|
||||||
|
CONFIG_DIR="$HOME_DIR/config"
|
||||||
|
DATA_DIR="$HOME_DIR/data"
|
||||||
|
|
||||||
|
mkdir $CONFIG_DIR
|
||||||
|
mkdir $DATA_DIR
|
||||||
|
|
||||||
|
SEEDS_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/$CHAINID/cl-seeds.txt"
|
||||||
|
|
||||||
|
env
|
||||||
|
|
||||||
|
if /0g/bin/0gchaind init ${MONIKER} --home $HOME_DIR; then
|
||||||
|
cp -r /0g/0g-home/0gchain-home/config/* $CONFIG_DIR
|
||||||
|
else
|
||||||
|
echo "Already initialized, continuing!" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /0g/bin/0gchaind $@
|
||||||
Reference in New Issue
Block a user