Skip to content

Commit

Permalink
Merge pull request #15 from spitzlbergerj/development
Browse files Browse the repository at this point in the history
Installationsskript fertiggestellt
  • Loading branch information
spitzlbergerj authored Mar 14, 2024
2 parents bf9021c + 740eef3 commit 1cfb5ca
Show file tree
Hide file tree
Showing 14 changed files with 1,253 additions and 280 deletions.
57 changes: 57 additions & 0 deletions .backup-config/backup2ndScript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# --------------------------------------------------
# Backup Skript fuer Raspberrys mit Config Dateien
# (c) Josef Spitzlberger, 03.12.2022
#
# 2. Skript fuer Sondersituationen in denen es nicht ausreicht, Dateien anzugeben
# --------------------------------------------------

# --------------------------------------------------
# Parameter uebernehmen
# --------------------------------------------------

BACKUP_DIR=$1

# --------------------------------------------------
# als 2. Skript melden
# --------------------------------------------------
echo "----------------------------------------------------"
echo " 2. Skript gestartet"
echo "----------------------------------------------------"

# --------------------------------------------------
# Sonderkommandos zum Sichern
# --------------------------------------------------

# --------------------------------------------------
# MariaDB
# --------------------------------------------------

# Maria DB

#
# Kommandos
MYSQL_CMD=/usr/bin/mysql
MYSQL_DMP=/usr/bin/mysqldump

# Backup
#
echo
echo "Starte Datenbanksicherung ..."
mkdir -p "$BACKUP_DIR/MariaDB"
databases=`$MYSQL_CMD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`

for db in $databases; do
echo "Sichere Datenbank $db ..."
$MYSQL_DMP --no-data --databases "$db" > "$BACKUP_DIR/MariaDB/$db-schema.sql"
$MYSQL_DMP --force --opt --databases "$db" | gzip > "$BACKUP_DIR/MariaDB/$db.gz"
done

# --------------------------------------------------
# 2. Skript beenden
# --------------------------------------------------
echo "----------------------------------------------------"
echo " 2. Skript abgeschlossen"
echo "----------------------------------------------------"

exit 0
4 changes: 4 additions & 0 deletions .backup-config/backup_dirs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/home/pi/CaravanPi/defaults
/home/pi/MagicMirror/css/custom.css
/home/pi/MagicMirror/config/config.js
/usr/local/bin/pishutdown.py
4 changes: 4 additions & 0 deletions .backup-config/backup_name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CaravanPiSSD
15
LGBsharepoint
Backup/Geraete/Raspberry
7 changes: 0 additions & 7 deletions .crontabs/crontab-pi
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
# 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
00-59/10 * * * * python3 -u /home/pi/CaravanPi/temperature/temp2file.py >/home/pi/CaravanPi/.log/temp2file.log 2>&1

Expand Down Expand Up @@ -54,8 +50,5 @@
#@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

# Zeit zwischen StromPi und Raspberry Pi synchronisieren
@reboot python /home/pi/StromPi3/RTCSerial.py >/home/pi/CaravanPi/.log/StromPi-RTC-sync.log 2>&1
7 changes: 0 additions & 7 deletions .crontabs/crontab-root
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
#
# 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/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
#
Expand Down
11 changes: 11 additions & 0 deletions .git_hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ACHTUNG:
Damit die git hooks funktionieren müssen die beiden Dateien hier ins Verzeichnis .git/hooks kopiert werden.

Außerdem muss ein Verzeichnis .git_sensible_backup angelegt werden

Hier die Kommandos

cd ~/CaravanPi
cp .git_hooks/*commit .git/hooks
chmod +x .git/hooks/*commit
mkdir ~/CaravanPi/.git_sensible_backup
4 changes: 4 additions & 0 deletions .lib/CaravanPiFilesClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,16 @@ def writeCaravanPiDefaults(self, config_dict):
"stromPiInstalled",
"gassensorInstalled",
"gassensorAlarmActive",
"gassensorAlarmResume",
"v230CheckInstalled",
"v230CheckAlarmActive",
"v230CheckAlarmResume",
"v12BatteryCheckInstalled",
"v12BatteryCheckAlarmActive",
"v12BatteryCheckAlarmResume",
"v12CarCheckInstalled",
"v12CarCheckAlarmActive",
"v12CarCheckAlarmResume",
]:
if key in config_dict:
config_dict[key] = '1' if config_dict[key] else '0'
Expand Down
16 changes: 16 additions & 0 deletions .systemd-files/flask.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Flask Webserver
After=network.target

[Service]
User=pi
WorkingDirectory=/home/pi/CaravanPi/html-flask
ExecStart=/usr/bin/python3 -u /home/pi/CaravanPi/html-flask/flask-main.py
Restart=always
# Logdateien Umleitung, dabei unbuffered einschalten
Environment=PYTHONUNBUFFERED=1
StandardOutput=append:/home/pi/CaravanPi/.log/flask-main.log
StandardError=append:/home/pi/CaravanPi/.log/flask-main.log

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions .systemd-files/pir.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Bewegungsmelder
After=network.target

[Service]
WorkingDirectory=/home/pi/CaravanPi/pir
ExecStart=/usr/bin/python3 -u /home/pi/CaravanPi/pir/pir.py 120 1
Restart=always
# Logdateien Umleitung, dabei unbuffered einschalten
Environment=PYTHONUNBUFFERED=1
StandardOutput=append:/home/pi/CaravanPi/.log/pir.log
StandardError=append:/home/pi/CaravanPi/.log/pir.log

[Install]
WantedBy=multi-user.target
75 changes: 45 additions & 30 deletions MagicMirror/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ modules: [
module: "MMM-SimpleLogo",
position: "top_center",
config: {
fileUrl: "modules/MMM-SimpleLogo/public/CaravanPi-Logo.png",
fileUrl: "modules/MMM-SimpleLogo/public/CaravanPi-Logo-weiss.png",
width: "220px",
position: "center",
text: "",
Expand Down Expand Up @@ -99,6 +99,33 @@ modules: [
* CaravanPi Module
* **********************************************************
*/

// bevorzugt nicht mehr die MMM-CaravanPi-xxx einbinden, sondern Grafana Grafen

/* -------------
{
module: 'MMM-GrafanaEmbedded',
position: 'top_right', // This can be any of the regions.
config: {
// http://192.168.178.139:3000/d/mef4p9ZVz/caravanpi-temperaturen?orgId=1&viewPanel=1
id: "mef4p9ZVz",
host: "192.168.178.139",
port: 3000,
dashboardName: "caravanpi-temperaturen",
orgId: 1,
panelId: 1,
width: "450",
height: "200",
refreshRate: "5m",
from: "now-36h",
to: "now",
}
},
--------------- */



/* -------------
{
module: "MMM-CaravanPiClimate",
position: "top_left",
Expand All @@ -121,7 +148,9 @@ modules: [
]
}
},
--------------- */

/* -------------
{
module: "MMM-CaravanPiTemperature",
position: "top_left",
Expand All @@ -146,7 +175,9 @@ modules: [
]
}
},
--------------- */

/* -------------
{
module: "MMM-CaravanPiGasWeight",
position: "top_left",
Expand All @@ -160,16 +191,17 @@ modules: [
name: "Alu 6kg Flasche 1",
file: "gasScale1",
},
/*
{
name: "Alu 8kg Flasche 2",
file: "gasScale2",
},
*/
]
}
},
--------------- */

/* -------------
{
module: "MMM-CaravanPiPosition",
position: "top_left",
Expand All @@ -184,13 +216,16 @@ modules: [
]
}
},
--------------- */



/* **********************************************************
* weitere Module - Vorschläge
* **********************************************************
*/

/*
/* -------------
{
module: 'MMM-DWD-WarnWeather',
position: 'top_right',
Expand All @@ -207,30 +242,9 @@ modules: [
severityThreshold: 2,
}
},
*/

/*
{
module: 'MMM-GrafanaEmbedded',
position: 'top_right', // This can be any of the regions.
config: {
/* http://192.168.178.139:3000/d/mef4p9ZVz/caravanpi-temperaturen?orgId=1&viewPanel=1 */
id: "mef4p9ZVz",
host: "192.168.178.139",
port: 3000,
dashboardName: "caravanpi-temperaturen",
orgId: 1,
panelId: 1,
width: "450",
height: "200",
refreshRate: "5m",
from: "now-36h",
to: "now",
}
},
*/
--------------- */

/*
/* -------------
{
module: "newsfeed",
position: "top_right", // This can be any of the regions. Best results in center regions.
Expand All @@ -254,9 +268,9 @@ modules: [
]
}
},
*/
--------------- */

/*
/* -------------
{
module: 'MMM-SystemStats',
position: 'bottom_bar',
Expand All @@ -268,7 +282,8 @@ modules: [
singleRow: true,
}
},
*/
--------------- */


/* **********************************************************
* Remote Control Modul
Expand Down
11 changes: 10 additions & 1 deletion analogSignals/v12Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,16 @@ def main():
print("Alarm in Config einschalten")
cplib.writeCaravanPiConfigItem(f"caravanpiDefaults/{v12xmlItemAlarm}", 1)
v12CheckAlarmActive = True


cplib = CaravanPiFiles()
cplib.handle_sensor_values(
args.screen, # Anzeige am Bildschirm?
"Spannung", # sensor_name = Datenbankname
f"12v{args.battery}", # sensor_id = Filename und Spalte in der Datenbank
["spannung"], # Liste Spaltennamen
(berechne_spannungsteiler(v12R1, v12R2, Vout=channel.voltage)) # Tupel Sensorwerte
)

time.sleep(delayAlarm if v12DropDetected else delay)

except Exception as e:
Expand Down
12 changes: 6 additions & 6 deletions defaults/caravanpiConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<gassensorAlarmActive>1</gassensorAlarmActive>
<v230CheckInstalled>1</v230CheckInstalled>
<v230CheckADCPin>0</v230CheckADCPin>
<v230CheckAlarmActive>0</v230CheckAlarmActive>
<v230CheckAlarmActive>1</v230CheckAlarmActive>
<v12BatteryCheckInstalled>1</v12BatteryCheckInstalled>
<v12BatteryCheckADCPin>2</v12BatteryCheckADCPin>
<v12BatteryCheckAlarmActive>0</v12BatteryCheckAlarmActive>
Expand All @@ -41,13 +41,13 @@
<v12BatteryR2>150</v12BatteryR2>
<v12CarR1>560</v12CarR1>
<v12CarR2>150</v12CarR2>
<gassensorAlarmResume>True</gassensorAlarmResume>
<v230CheckAlarmResume>True</v230CheckAlarmResume>
<v12BatteryCheckAlarmResume>True</v12BatteryCheckAlarmResume>
<v12CarCheckAlarmResume>True</v12CarCheckAlarmResume>
<gassensorAlarmResume>0</gassensorAlarmResume>
<v230CheckAlarmResume>0</v230CheckAlarmResume>
<v12BatteryCheckAlarmResume>0</v12BatteryCheckAlarmResume>
<v12CarCheckAlarmResume>1</v12CarCheckAlarmResume>
</caravanpiDefaults>
<adjustmentPosition>
<adjustX>-0.0392266</adjustX>
<adjustX>-0.0392267</adjustX>
<adjustY>1.5298374</adjustY>
<adjustZ>8.9044382</adjustZ>
<toleranceX>0.2</toleranceX>
Expand Down
Loading

0 comments on commit 1cfb5ca

Please sign in to comment.