-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add caravanpiConfig.xml to version control
- Loading branch information
Showing
182 changed files
with
11,896 additions
and
1,463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.