#!/bin/bash
# Start Redpanda - Corrected for v24.3.14
# Generate config first, then start
/usr/bin/rpk redpanda config init --overprovisioned

# Set configuration via rpk config set
/usr/bin/rpk config set redpanda.node_id 0
/usr/bin/rpk config set redpanda.data_directory /var/lib/redpanda/data
/usr/bin/rpk config set redpanda.kafka_api "[{'address': '0.0.0.0', 'port': 9092}]"
/usr/bin/rpk config set redpanda.advertised_kafka_api "[{'address': 'smart-city-redpanda', 'port': 9092}]"
/usr/bin/rpk config set redpanda.admin "[{'address': '0.0.0.0', 'port': 9644}]"
/usr/bin/rpk config set redpanda.rpc_server "[{'address': '0.0.0.0', 'port': 33145}]"
/usr/bin/rpk config set redpanda.seed_servers "[]"
/usr/bin/rpk config set seastar.smp 1
/usr/bin/rpk config set seastar.memory 1G
/usr/bin/rpk config set seastar.overprovisioned true

# Start Redpanda
exec /usr/bin/rpk redpanda start --check=false
