#!/bin/bash # Startet die Wattpilot-Bruecke (wattpilotshell) neu. # # Zugangsdaten kommen aus config.ini und stehen nicht mehr hier im Skript - # frueher stand das Wattpilot-Passwort im Klartext in der ersten Zeile. BASIS="/volume1/homes/wagner/SolarManager" # Einen Wert aus config.ini lesen: konf konf() { awk -v abschnitt="[$1]" -v schluessel="$2" ' $0 == abschnitt { drin = 1; next } /^\[/ { drin = 0 } drin && $0 ~ "^" schluessel " *=" { sub(/^[^=]*= */, ""); print; exit } ' "$BASIS/config.ini" } export MQTT_ENABLED=true export MQTT_HOST=$(konf wattpilot mqtt_host) export WATTPILOT_HOST=$(konf wattpilot host) export WATTPILOT_PASSWORD=$(konf wattpilot password) if [ -z "$WATTPILOT_PASSWORD" ]; then echo "config.ini: [wattpilot] password fehlt - Abbruch" exit 1 fi echo "Starting..." # Change the name of the script here SCRIPT_NAME="wattpilotshell" LOG_FILE="wattpilotshell.log" # Find the process ID of any running instance of the script PID=$(ps aux | grep "$SCRIPT_NAME" | grep -v grep | awk '{print $2}') # If a running instance was found, kill it if [[ -n "$PID" ]]; then echo "Killing process $PID" kill $PID fi # Start the script cd "$BASIS" /var/services/homes/wagner/.local/bin/wattpilotshell server &> "$LOG_FILE" &