Fix config files mancanti quando volume mount è vuoto
Build Docker Image for Raspberry Pi / build-and-push (push) Successful in 6m52s
Build Docker Image for Raspberry Pi / build-and-push (push) Successful in 6m52s
- Aggiunto check all'avvio per verificare esistenza inverter.conf e mqtt.json - Se mancanti, crea file di default automaticamente - Risolve problema volume mount che sovrascrive file copiati in build - Config default con valori standard funzionanti - ENV variables sovrascrivono comunque i default tramite update_mqtt_config() Ora il container parte anche con directory ./config vuota
This commit is contained in:
@@ -7,9 +7,44 @@ echo ""
|
|||||||
|
|
||||||
# Configuration paths
|
# Configuration paths
|
||||||
CONF_FILE="/etc/inverter/inverter.conf"
|
CONF_FILE="/etc/inverter/inverter.conf"
|
||||||
|
MQTT_CONF="/etc/inverter/mqtt.json"
|
||||||
DISCOVERY_FLAG="/etc/inverter/.discovery_done"
|
DISCOVERY_FLAG="/etc/inverter/.discovery_done"
|
||||||
TEMP_CONF="/tmp/inverter_discovered.conf"
|
TEMP_CONF="/tmp/inverter_discovered.conf"
|
||||||
|
|
||||||
|
# Ensure config files exist (copy defaults if missing due to empty volume mount)
|
||||||
|
if [ ! -f "$CONF_FILE" ]; then
|
||||||
|
echo "⚠ inverter.conf not found, creating default..."
|
||||||
|
cat > "$CONF_FILE" << 'EOF'
|
||||||
|
# Basic configuration options for the actual inverter polling process...
|
||||||
|
device=/dev/ttyUSB0
|
||||||
|
run_interval=120
|
||||||
|
amperage_factor=1.0
|
||||||
|
watt_factor=1.01
|
||||||
|
qpiri=103
|
||||||
|
qpiws=40
|
||||||
|
qmod=5
|
||||||
|
qpigs=110
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$MQTT_CONF" ]; then
|
||||||
|
echo "⚠ mqtt.json not found, creating default..."
|
||||||
|
cat > "$MQTT_CONF" << 'EOF'
|
||||||
|
{
|
||||||
|
"server": "192.168.1.37",
|
||||||
|
"port": "1883",
|
||||||
|
"topic": "homeassistant",
|
||||||
|
"devicename": "voltronic",
|
||||||
|
"username": "",
|
||||||
|
"password": "",
|
||||||
|
"clientid": "voltronic_default",
|
||||||
|
"influx": {
|
||||||
|
"enabled": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
# Environment variables with defaults
|
# Environment variables with defaults
|
||||||
INVERTER_DEVICE="${INVERTER_DEVICE:-/dev/ttyUSB0}"
|
INVERTER_DEVICE="${INVERTER_DEVICE:-/dev/ttyUSB0}"
|
||||||
FORCE_DISCOVERY="${FORCE_DISCOVERY:-false}"
|
FORCE_DISCOVERY="${FORCE_DISCOVERY:-false}"
|
||||||
|
|||||||
Reference in New Issue
Block a user