#!/bin/sh if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then set -x fi # TODO: Read from env MONIKER=MyNode CHAIN_ID=laconic_9000-1 GENESIS_FILE_URL="/root/.laconicd/config/genesis.json" PEERS="" LOGLEVEL="info" if [ -z "$PEERS" ]; then echo "Persistent peers not provided, exiting..." exit 1 else echo "Using persistent peers $PEERS" fi echo "Env:" echo "Moniker: $MONIKER" echo "Chain Id: $CHAIN_ID" echo "Genesis file: $GENESIS_FILE_URL" echo "Persistent peers: $PEERS" NODE_HOME=/root/.laconicd # Set chain id in config laconicd config set client chain-id $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 $MONIKER and chain id $CHAIN_ID" laconicd init $MONIKER --chain-id=$CHAIN_ID --home $NODE_HOME # Fetch genesis config echo "Fetching genesis file from $GENESIS_FILE_URL" curl -o $NODE_HOME/config/genesis.json $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 = \"$PEERS\"/g" $NODE_HOME/config/config.toml laconicd start --gql-playground --gql-server --log_level $LOGLEVEL --home $NODE_HOME