#!/bin/sh
# Generate icecast.xml from base config
# - Substitute hostname (defaults to localhost for dev)
# - If ICECAST_ENABLE_YP=true, insert YP directory blocks
cp /etc/icecast-base.xml /etc/icecast.xml
# Set hostname (defaults to localhost if not specified)
ICECAST_HOSTNAME=${ICECAST_HOSTNAME:-localhost}
echo "Icecast hostname: $ICECAST_HOSTNAME"
sed -i "s|localhost|$ICECAST_HOSTNAME|" /etc/icecast.xml
if [ "$ICECAST_ENABLE_YP" = "true" ]; then
echo "YP directory publishing ENABLED"
# Insert YP config before closing tag
sed -i 's||'"$(cat /etc/icecast-yp-snippet.xml)"'\n|' /etc/icecast.xml
else
echo "YP directory publishing DISABLED (dev mode)"
fi
# Start icecast
exec icecast -c /etc/icecast.xml