22 lines
961 B
Bash
Executable File
22 lines
961 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
# 🛡️ [OmniOil] Ensure data and log directories have correct permissions
|
|
# Mosquitto runs as UID 1883, we need to make sure it can write to the volumes
|
|
echo "🔐 [OmniOil] Fixing permissions for /mosquitto/data and /mosquitto/log..."
|
|
mkdir -p /mosquitto/data /mosquitto/log
|
|
chown -R mosquitto:mosquitto /mosquitto/data /mosquitto/log
|
|
|
|
# Generar el archivo final a partir de la plantilla
|
|
TEMPLATE="/etc/mosquitto/mosquitto.conf.template"
|
|
CONFIG="/etc/mosquitto/mosquitto.conf"
|
|
|
|
echo "🔧 [OmniOil] Generating configuration from environment variables..."
|
|
# Usamos | como delimitador para soportar caracteres especiales en contraseñas
|
|
sed "s|POSTGRES_HOST_PLACEHOLDER|$POSTGRES_HOST|g; \
|
|
s|POSTGRES_USER_PLACEHOLDER|$POSTGRES_USER|g; \
|
|
s|POSTGRES_PASSWORD_PLACEHOLDER|$POSTGRES_PASSWORD|g; \
|
|
s|POSTGRES_DB_PLACEHOLDER|$POSTGRES_DB|g" $TEMPLATE > $CONFIG
|
|
|
|
echo "🚀 Starting Mosquitto..."
|
|
exec /usr/sbin/mosquitto -c $CONFIG |