45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
|
set -x
|
|
fi
|
|
|
|
set -e
|
|
|
|
if [ -z "$CERC_PEERS" ]; then
|
|
echo "Persistent peers not provided, exiting..."
|
|
exit 1
|
|
else
|
|
echo "Using persistent peers $CERC_PEERS"
|
|
fi
|
|
|
|
echo "Env:"
|
|
echo "Moniker: $CERC_MONIKER"
|
|
echo "Chain Id: $CERC_CHAIN_ID"
|
|
echo "Genesis file: $CERC_GENESIS_FILE_URL"
|
|
echo "Persistent peers: $CERC_PEERS"
|
|
echo "Log level: $CERC_LOGLEVEL"
|
|
|
|
NODE_HOME=/root/.laconicd
|
|
|
|
# Set chain id in config
|
|
laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME
|
|
|
|
# Check if node data dir already exists
|
|
if [ -z "$(ls -A "$NODE_HOME/data")" ]; then
|
|
# Init node
|
|
echo "Initializing a new laconicd node with moniker $CERC_MONIKER and chain id $CERC_CHAIN_ID"
|
|
laconicd init $CERC_MONIKER --chain-id=$CERC_CHAIN_ID --home $NODE_HOME
|
|
|
|
# Fetch genesis config
|
|
echo "Fetching genesis file from $CERC_GENESIS_FILE_URL"
|
|
curl -o $NODE_HOME/config/genesis.json $CERC_GENESIS_FILE_URL
|
|
else
|
|
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
|
fi
|
|
|
|
# Update config with persistent peers
|
|
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
|
|
|
laconicd start --gql-playground --gql-server --log_level $CERC_LOGLEVEL --home $NODE_HOME
|