transcriptor/entrypoint.sh
2025-02-20 15:14:36 +01:00

13 lines
555 B
Bash
Executable File

#!/bin/sh
# Get container hostname, e.g. "scanner_1", "scanner_2", etc.
HOST="$(hostname)"
# Extract the numeric suffix (assumes hostname format "scanner_N")
INDEX=$(echo "$HOST" | awk -F '-' '{print $NF}')
# Adjust to zero-index (container 1 corresponds to index 0)
INDEX_ZERO=$((INDEX - 1))
# Read the channel name from channels.json using jq (which must be installed)
CHANNEL=$(jq -r ".[$INDEX_ZERO]" /app/channels.json)
export CHANNEL_NAME="$CHANNEL"
echo "Container $HOST using CHANNEL_NAME: $CHANNEL_NAME"
# Run the Python script
exec python main.py