Skip to content

Commit

Permalink
Add caravanpiConfig.xml to version control
Browse files Browse the repository at this point in the history
  • Loading branch information
upgrade_script committed Mar 10, 2024
2 parents 3c28bcb + 99e90b7 commit 6e3e00e
Show file tree
Hide file tree
Showing 182 changed files with 11,896 additions and 1,463 deletions.
37 changes: 31 additions & 6 deletions .crontabs/crontab-pi
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
#
# min hour dayofmonth month dayofweek(0=Sonntag) command
#


# Python-Flask starten für die CaravanPi Websites
@reboot python3 -u /home/pi/CaravanPi/html-flask/flask-main.py >/home/pi/CaravanPi/.log/flask-main.log 2>&1

# Temperatursensoren alle 60 Sekunden auslesen
* * * * * python3 -u /home/pi/CaravanPi/temperature/temp2file.py >/home/pi/CaravanPi/.log/temp2file.log 2>&1
00-59/10 * * * * python3 -u /home/pi/CaravanPi/temperature/temp2file.py >/home/pi/CaravanPi/.log/temp2file.log 2>&1

# Gasflaschenwaage alle 60 Sekunden auslesen
* * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 1 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1
01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 1 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1
01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 2 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1

# Klimasensoren alle 60 Sekunden auslesen
* * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py 76 1 >/home/pi/CaravanPi/.log/climate2file76.log 2>&1
* * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py 77 1 >/home/pi/CaravanPi/.log/climate2file77.log 2>&1
02-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 76 >/home/pi/CaravanPi/.log/climate2file76.log 2>&1
#03-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 77 >/home/pi/CaravanPi/.log/climate2file77.log 2>&1

# Lagesensor auslesen, Zeitsteuerung im Skript inkl. Live Modus
@reboot python3 -u /home/pi/CaravanPi/position/position2file.py -f >/home/pi/CaravanPi/.log/position2file.log 2>&1
Expand All @@ -27,10 +33,29 @@

# Füllmenge Tanks auslesen
@reboot python3 -u /home/pi/CaravanPi/levels/freshLevels2file.py -t 1 -f >/home/pi/CaravanPi/.log/levels.log 2>&1
* * * * * python3 -u /home/pi/CaravanPi/levels/wasteLevels2file.py -t 2 -f >/home/pi/CaravanPi/.log/levels.log 2>&1
#04-59/10 * * * * python3 -u /home/pi/CaravanPi/levels/wasteLevels2file.py -t 2 -f >/home/pi/CaravanPi/.log/levels.log 2>&1

# Batteriemanagement auslesen
05-59/10 * * * * python3 -u /home/pi/CaravanPi/batteryMgmt/bms2file.py >/home/pi/CaravanPi/.log/bms2file.log 2>&1

# Systemdaten Raspberry Pi lesen
@reboot python3 -u /home/pi/CaravanPi/raspberrypi/systemstat2file.py >/home/pi/CaravanPi/.log/systemstat.log 2>&1

# MariaDB bereinigen, jeden Montag 01:05
05 01 * * 1 python3 -u /home/pi/CaravanPi/raspberrypi/clean_MariaDB.py -d 150 >/home/pi/CaravanPi/.log/cleanMariaDB.log 2>&1

# Gassensor überwachen
@reboot python3 -u /home/pi/CaravanPi/analogSignals/gassensorCheck.py >/home/pi/CaravanPi/.log/gassensorCheck.log 2>&1

# 230V Eingang überwachen
@reboot python3 -u /home/pi/CaravanPi/analogSignals/v230Check.py >/home/pi/CaravanPi/.log/v230Check.log 2>&1

# 12V Eingang überwachen
#@reboot python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "car" >/home/pi/CaravanPi/.log/v12Check.log 2>&1
@reboot python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "bord" >/home/pi/CaravanPi/.log/v12Check.log 2>&1

# Webservice bottleFramework starten
@reboot python3 -u /home/pi/CaravanPi/bottleFramework/bottleCommands.py >/home/pi/CaravanPi/.log/bottleCommands.log 2>&1
#@reboot python3 -u /home/pi/CaravanPi/bottleFramework/bottleCommands.py >/home/pi/CaravanPi/.log/bottleCommands.log 2>&1

# Zeit zwischen StromPi und Raspberry Pi synchronisieren
@reboot python /home/pi/StromPi3/RTCSerial.py >/home/pi/CaravanPi/.log/StromPi-RTC-sync.log 2>&1
8 changes: 3 additions & 5 deletions .crontabs/crontab-root
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# crontab root
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# min hour dayofmonth month dayofweek(0=Sonntag) command
#
# beim Neustart Skript fuer Sensor starten
Expand All @@ -13,8 +10,9 @@
# 05 20 * * * /usr/local/bin/backup.sh > /home/pi/CaravanPi/.log/backup.log 2>&1
#
# Backup Dateien starten
@reboot sleep 300 && /home/pi/CaravanPi/backup/backup-caravanpi.sh > /home/pi/CaravanPi/.log/backup-caravanpi.log 2>&1
01 02 * * * /home/pi/CaravanPi/backup/backup-caravanpi.sh > /home/pi/CaravanPi/.log/backup-caravanpi.log 2>&1

@reboot sleep 300 && /home/pi/backup/backup.sh >>/home/pi/CaravanPi/.log/backup.log 2>&1
01 02 * * * /home/pi/backup/backup.sh >>/home/pi/CaravanPi/.log/backup.log 2>&1
#
# Logrotate starten
@reboot sleep 300 && logrotate /etc/logrotate.conf
Expand Down
19 changes: 19 additions & 0 deletions .crontabs/crontab-root-initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# crontab root
#
# min hour dayofmonth month dayofweek(0=Sonntag) command
#
# beim Neustart Skript fuer Sensor starten
# @reboot python3 /home/pi/CaravanPi/pir/pir.py 120 1 > /home/pi/CaravanPi/.log/pir.log 2>&1

# Backup Image starten (Sonntags)
# 01 03 * * 0 /usr/local/bin/backup.sh > /home/pi/CaravanPi/.log/backup.log 2>&1
# 05 20 * * * /usr/local/bin/backup.sh > /home/pi/CaravanPi/.log/backup.log 2>&1
#
# Backup Dateien starten
# @reboot sleep 300 && /home/pi/CaravanPi/backup/backup-caravanpi.sh > /home/pi/CaravanPi/.log/backup-caravanpi.log 2>&1
# 01 02 * * * /home/pi/CaravanPi/backup/backup-caravanpi.sh > /home/pi/CaravanPi/.log/backup-caravanpi.log 2>&1
#
# Logrotate starten
@reboot sleep 300 && logrotate /etc/logrotate.conf
00 05 * * * logrotate /etc/logrotate.conf

17 changes: 17 additions & 0 deletions .git_hooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Pfad zu den Dateien und zum Backup-Verzeichnis
CONFIG_XML="defaults/caravanpiConfig.xml"
README_MD="defaults/README.md"
BACKUP_DIR=".git_sensible_backup"

# Wiederherstellungsfunktion
restore_files() {
mv "$BACKUP_DIR/$(basename $1).backup" "$1"
}

# Dateien nach dem Commit wiederherstellen
restore_files "$CONFIG_XML"
restore_files "$README_MD"

exit 0
43 changes: 43 additions & 0 deletions .git_hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
#
# Sensible Daten sollen aus Dateien entfernt werden
# Crontabs sollen in .crontabs gesichert werden

# Pfad zu den Dateien und zum Backup-Verzeichnis
CONFIG_XML="defaults/caravanpiConfig.xml"
README_MD="defaults/README.md"
BACKUP_DIR=".git_sensible_backup"
CRONTABS_DIR="/home/pi/CaravanPi/.crontabs"

# Backup-Funktion
backup_files() {
cp "$1" "$BACKUP_DIR/$(basename $1).backup"
}

# Dateien vor der Bearbeitung sichern
backup_files "$CONFIG_XML"
backup_files "$README_MD"

# Funktion, um die Dateien zu bearbeiten (wie zuvor)
update_files() {
sed -i 's/<MariaDBpasswd>[^<]*<\/MariaDBpasswd>/<MariaDBpasswd>dasGeheimePasswort<\/MariaDBpasswd>/' "$1"
sed -i 's/<MQTTpassword>[^<]*<\/MQTTpassword>/<MQTTpassword>dasGeheimePasswort<\/MQTTpassword>/' "$1"
sed -i 's/<MQTTbroker>[^<]*<\/MQTTbroker>/<MQTTbroker>MQTTBrokerWebAdresse<\/MQTTbroker>/' "$1"
}

# Dateien aktualisieren
update_files "$CONFIG_XML"
update_files "$README_MD"

# Crontab-Export hinzufügen
mkdir -p "$CRONTABS_DIR"
crontab -l > "$CRONTABS_DIR/crontab-pi"
sudo crontab -u root -l > "$CRONTABS_DIR/crontab-root" 2>/dev/null

# Fügen Sie die geänderten Dateien dem Commit hinzu
git add "$CONFIG_XML"
git add "$README_MD"
git add "$CRONTABS_DIR/crontab-pi"
git add "$CRONTABS_DIR/crontab-root"

exit 0
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
# ignoriere logrotate Steuerung
logrotate.status

# ignoriere .git-sensible-backup
.git_sensible_backup

# ignoriere alle python caches
__pycache__/

# ignoriere fremde libraries
.lib/__pycache__
.lib/__pycache__/*
.lib/hx711py
.lib/hx711py/*
.lib/hx711pySJJSJJSJJSJJ
.lib/hx711pySJJSJJSJJSJJ/*
.lib/*pyc
.lib/Adafruit_Python_ADS1x15

# ignoriere defaults/_allt, das durch abwaerttskompatibilitaet entsteht
defaults/_alt/

# Verzeichnis log (Loggig Daten)
# Verzeichnis anlegen
Expand Down
69 changes: 69 additions & 0 deletions .lib/CaravanPiActorsClass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/python3
# coding=utf-8
# CaravanPiActorsClass.py
#
# Class für das Ansprechen von Aktoren
#
#-------------------------------------------------------------------------------
import os
import time
import sys
import subprocess
import requests


class CaravanPiActors:

# -----------------------------------------------
# global variables
# -----------------------------------------------

# -----------------------------------------------
# Initialisieren
# -----------------------------------------------

def __init__(self):
# nichts zu tun
return


# -----------------------------------------------
# Universelle Funktion zum Senden von HTTP Requests
#
# method: Die HTTP-Methode ('GET', 'POST', etc.)
# url: Die URL für den Request
# kwargs: Zusätzliche Argumente für requests (z.B. json für POST-Daten)
# return: Das Response-Objekt
# -----------------------------------------------

def send_request(self, method, url, **kwargs):
try:
response = requests.request(method, url, **kwargs)
return response
except Exception as e:
print(f'Fehler beim Senden des Requests: {e}')
return None

# -----------------------------------------------
# Sendet einen HTTP-GET-Request.
#
# url: Die URL für den GET-Request
# params: Ein Dictionary mit URL-Parametern
# return: Das Response-Objekt
# -----------------------------------------------


def get(self, url, params=None):
return self.send_request('GET', url, params=params)

# -----------------------------------------------
# Sendet einen HTTP-POST-Request.
#
# url: Die URL für den POST-Request
# data: Das Dictionary mit Form-Daten
# json: Das Dictionary mit JSON-Daten
# return: Das Response-Objekt
# -----------------------------------------------

def post(self, url, data=None, json=None):
return self.send_request('POST', url, data=data, json=json)
Loading

0 comments on commit 6e3e00e

Please sign in to comment.