2024-06-19 04:33:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
input_genesis_file=/root/.laconicd/tmp/genesis.json
|
|
|
|
if [ ! -f ${input_genesis_file} ]; then
|
|
|
|
echo "Genesis file not provided, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$CERC_PEERS" ]; then
|
|
|
|
echo "Persistent peers not provided, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Env:"
|
|
|
|
echo "Moniker: $CERC_MONIKER"
|
|
|
|
echo "Chain Id: $CERC_CHAIN_ID"
|
|
|
|
echo "Persistent peers: $CERC_PEERS"
|
2024-10-30 12:05:54 +00:00
|
|
|
echo "Min gas price: $MIN_GAS_PRICE"
|
2024-06-19 04:33:56 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
# Use provided genesis config
|
|
|
|
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
|
|
|
else
|
|
|
|
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
|
|
|
fi
|
|
|
|
|
2024-10-30 12:05:54 +00:00
|
|
|
# Enable cors
|
|
|
|
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
|
|
|
|
|
2024-06-19 04:33:56 +00:00
|
|
|
# Update config with persistent peers
|
|
|
|
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
|
|
|
|
|
|
|
echo "Starting laconicd node..."
|
2024-06-24 07:26:38 +00:00
|
|
|
laconicd start \
|
|
|
|
--api.enable \
|
2024-10-30 12:05:54 +00:00
|
|
|
--minimum-gas-prices=${MIN_GAS_PRICE}alnt \
|
2024-06-24 07:26:38 +00:00
|
|
|
--rpc.laddr="tcp://0.0.0.0:26657" \
|
|
|
|
--gql-playground --gql-server \
|
|
|
|
--log_level $CERC_LOGLEVEL \
|
|
|
|
--home $NODE_HOME
|