2023-06-19 06:28:27 +00:00
|
|
|
NAME=""
|
|
|
|
if [ -n "$CODEX_NODENAME" ]; then
|
|
|
|
NAME=" '$CODEX_NODENAME'"
|
|
|
|
fi
|
|
|
|
echo "Starting Codex node$NAME"
|
2023-03-08 11:45:55 +00:00
|
|
|
|
|
|
|
args=""
|
|
|
|
|
2023-06-19 06:21:03 +00:00
|
|
|
## Using local ip as NAT
|
2023-06-19 09:00:21 +00:00
|
|
|
nat_addr=$(ifconfig eth0 | awk '/inet/ {gsub("addr:", "", $2); print $2}')
|
2023-06-19 06:21:03 +00:00
|
|
|
echo "Local IP: $nat_addr"
|
|
|
|
|
2023-03-08 11:45:55 +00:00
|
|
|
# Required arguments
|
2023-03-20 14:07:07 +00:00
|
|
|
if [ -n "$LISTEN_ADDRS" ]; then
|
|
|
|
echo "Listen address: $LISTEN_ADDRS"
|
|
|
|
args="$args --listen-addrs=$LISTEN_ADDRS"
|
|
|
|
else
|
|
|
|
args="$args --listen-addrs=/ip4/0.0.0.0/tcp/8071"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$API_BINDADDR" ]; then
|
|
|
|
echo "API bind address: $API_BINDADDR"
|
|
|
|
args="$args --api-bindaddr=$API_BINDADDR"
|
|
|
|
else
|
|
|
|
args="$args --api-bindaddr=0.0.0.0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$DATA_DIR" ]; then
|
|
|
|
echo "Data dir: $DATA_DIR"
|
|
|
|
args="$args --data-dir=$DATA_DIR"
|
|
|
|
else
|
|
|
|
args="$args --data-dir=/datadir"
|
|
|
|
fi
|
2023-03-08 11:45:55 +00:00
|
|
|
|
|
|
|
# Optional arguments
|
|
|
|
# Log level
|
|
|
|
if [ -n "$LOG_LEVEL" ]; then
|
|
|
|
echo "Log level: $LOG_LEVEL"
|
2023-06-19 06:28:27 +00:00
|
|
|
args="$args --log-level=\"$LOG_LEVEL\""
|
2023-03-08 11:45:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Metrics
|
|
|
|
if [ -n "$METRICS_ADDR" ] && [ -n "$METRICS_PORT" ]; then
|
|
|
|
echo "Metrics enabled"
|
|
|
|
args="$args --metrics=true"
|
|
|
|
args="$args --metrics-address=$METRICS_ADDR"
|
|
|
|
args="$args --metrics-port=$METRICS_PORT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# NAT
|
2023-06-19 06:21:03 +00:00
|
|
|
echo "NAT: $nat_addr"
|
|
|
|
args="$args --nat=$nat_addr"
|
2023-03-08 11:45:55 +00:00
|
|
|
|
|
|
|
# Discovery IP
|
|
|
|
if [ -n "$DISC_IP" ]; then
|
|
|
|
echo "Discovery IP: $DISC_IP"
|
|
|
|
args="$args --disc-ip=$DISC_IP"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Discovery Port
|
|
|
|
if [ -n "$DISC_PORT" ]; then
|
|
|
|
echo "Discovery Port: $DISC_PORT"
|
|
|
|
args="$args --disc-port=$DISC_PORT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Net private key
|
|
|
|
if [ -n "$NET_PRIVKEY" ]; then
|
|
|
|
echo "Network Private Key path: $NET_PRIVKEY"
|
|
|
|
args="$args --net-privkey=$NET_PRIVKEY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Bootstrap SPR
|
|
|
|
if [ -n "$BOOTSTRAP_SPR" ]; then
|
|
|
|
echo "Bootstrap SPR: $BOOTSTRAP_SPR"
|
|
|
|
args="$args --bootstrap-node=$BOOTSTRAP_SPR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Max peers
|
|
|
|
if [ -n "$MAX_PEERS" ]; then
|
|
|
|
echo "Max peers: $MAX_PEERS"
|
|
|
|
args="$args --max-peers=$MAX_PEERS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Agent string
|
|
|
|
if [ -n "$AGENT_STRING" ]; then
|
|
|
|
echo "Agent string: $AGENT_STRING"
|
|
|
|
args="$args --agent-string=$AGENT_STRING"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# API port
|
|
|
|
if [ -n "$API_PORT" ]; then
|
|
|
|
echo "API port: $API_PORT"
|
|
|
|
args="$args --api-port=$API_PORT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Storage quota
|
|
|
|
if [ -n "$STORAGE_QUOTA" ]; then
|
|
|
|
echo "Storage quote: $STORAGE_QUOTA"
|
|
|
|
args="$args --storage-quota=$STORAGE_QUOTA"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Block TTL
|
|
|
|
if [ -n "$BLOCK_TTL" ]; then
|
|
|
|
echo "Block TTL: $BLOCK_TTL"
|
|
|
|
args="$args --block-ttl=$BLOCK_TTL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cache size
|
|
|
|
if [ -n "$CACHE_SIZE" ]; then
|
|
|
|
echo "Cache size: $CACHE_SIZE"
|
|
|
|
args="$args --cache-size=$CACHE_SIZE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ethereum persistence
|
2023-06-19 09:00:21 +00:00
|
|
|
if [ -n "$ETH_PROVIDER" ]; then
|
|
|
|
echo "Provider: $ETH_PROVIDER"
|
2023-03-08 11:45:55 +00:00
|
|
|
args="$args --eth-provider=$ETH_PROVIDER"
|
2023-06-19 09:00:21 +00:00
|
|
|
fi
|
2023-04-18 12:17:24 +00:00
|
|
|
|
2023-06-19 06:28:27 +00:00
|
|
|
if [ -n "$ETH_ACCOUNT" ]; then
|
|
|
|
echo "Ethereum account: $ETH_ACCOUNT"
|
|
|
|
args="$args --eth-account=$ETH_ACCOUNT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ETH_MARKETPLACE_ADDRESS" ]; then
|
|
|
|
# Remove this as soon as CLI option is available:
|
|
|
|
echo "{\"contracts\": { \"Marketplace\": { \"address\": \""$ETH_MARKETPLACE_ADDRESS"\" } } }" > /root/marketplace_address.json
|
|
|
|
args="$args --eth-deployment=/root/marketplace_address.json"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$SIMULATE_PROOF_FAILURES" ]; then
|
|
|
|
echo "Simulate proof failures: $SIMULATE_PROOF_FAILURES"
|
|
|
|
args="$args --simulate-proof-failures=$SIMULATE_PROOF_FAILURES"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$PERSISTENCE" = "true" ] || [ "$PERSISTENCE" = "1" ]; then
|
|
|
|
echo "Persistence enabled"
|
|
|
|
args="$args --persistence"
|
|
|
|
else
|
|
|
|
echo "Persistence disabled"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$VALIDATOR" = "true" ] || [ "$VALIDATOR" = "1" ]; then
|
|
|
|
echo "Validator enabled"
|
|
|
|
args="$args --validator"
|
|
|
|
else
|
|
|
|
echo "Validator disabled"
|
2023-03-08 11:45:55 +00:00
|
|
|
fi
|
|
|
|
|
2023-06-19 06:28:27 +00:00
|
|
|
echo "./codex $args"
|
|
|
|
/bin/bash -l -c "./codex $args"
|