2024-06-18 05:16:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-05-20 11:27:41 +00:00
|
|
|
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
2024-06-18 05:16:09 +00:00
|
|
|
set -x
|
2024-05-20 11:27:41 +00:00
|
|
|
fi
|
|
|
|
|
2024-06-18 05:16:09 +00:00
|
|
|
set -e
|
2024-05-20 11:27:41 +00:00
|
|
|
|
2024-06-18 10:19:39 +00:00
|
|
|
input_genesis_file=/root/.laconicd/tmp/genesis.json
|
|
|
|
if [ ! -f ${input_genesis_file} ]; then
|
|
|
|
echo "Genesis file not provided, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-18 05:16:09 +00:00
|
|
|
if [ -z "$CERC_PEERS" ]; then
|
2024-06-17 13:46:19 +00:00
|
|
|
echo "Persistent peers not provided, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Env:"
|
2024-06-18 05:16:09 +00:00
|
|
|
echo "Moniker: $CERC_MONIKER"
|
|
|
|
echo "Chain Id: $CERC_CHAIN_ID"
|
|
|
|
echo "Persistent peers: $CERC_PEERS"
|
|
|
|
echo "Log level: $CERC_LOGLEVEL"
|
2024-06-17 13:46:19 +00:00
|
|
|
|
|
|
|
NODE_HOME=/root/.laconicd
|
|
|
|
|
|
|
|
# Set chain id in config
|
2024-06-18 05:16:09 +00:00
|
|
|
laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME
|
2024-06-17 13:46:19 +00:00
|
|
|
|
|
|
|
# Check if node data dir already exists
|
|
|
|
if [ -z "$(ls -A "$NODE_HOME/data")" ]; then
|
|
|
|
# Init node
|
2024-06-18 05:16:09 +00:00
|
|
|
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
|
2024-06-17 13:46:19 +00:00
|
|
|
|
2024-06-18 10:19:39 +00:00
|
|
|
# Use provided genesis config
|
|
|
|
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
2024-06-17 13:46:19 +00:00
|
|
|
else
|
|
|
|
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Update config with persistent peers
|
2024-06-18 05:16:09 +00:00
|
|
|
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
2024-05-20 11:27:41 +00:00
|
|
|
|
2024-06-18 07:13:37 +00:00
|
|
|
echo "Starting laconicd node..."
|
2024-06-18 05:16:09 +00:00
|
|
|
laconicd start --gql-playground --gql-server --log_level $CERC_LOGLEVEL --home $NODE_HOME
|