Compare commits
11
Commits
main
..
f07368b410
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f07368b410 | ||
|
|
0819331c2a | ||
|
|
3c44716253 | ||
|
|
5cd68fe317 | ||
|
|
b71ed56ded | ||
|
|
00efab2ba0 | ||
|
|
9e3e4e1ac3 | ||
|
|
fd6598fba9 | ||
|
|
70410aa08b | ||
|
|
9685c4ce8d | ||
|
|
311c8f37d7 |
@@ -1 +0,0 @@
|
|||||||
/ansible
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
In diesen Ordner werden Scripts für PiCam hinterlegt.
|
||||||
|
|
||||||
|
move_file_mount.sh verschiebt die Videodateien auf das NAS.
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Place under /etc/dnsmasq.d/99-dns-vip.conf
|
|
||||||
# This will propagate the DNS VIP of keepalived as DNS Server over DHCP
|
|
||||||
dhcp-option=option:dns-server,192.168.1.4
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# Place under /etc/keepalived/keepalived.conf on BACKUP pihole
|
|
||||||
global_defs {
|
|
||||||
router_id pihole-dns-02
|
|
||||||
script_user root
|
|
||||||
enable_script_security
|
|
||||||
}
|
|
||||||
|
|
||||||
vrrp_script chk_ftl {
|
|
||||||
script "/etc/scripts/chk_ftl"
|
|
||||||
interval 1
|
|
||||||
weight -10
|
|
||||||
}
|
|
||||||
|
|
||||||
vrrp_instance PIHOLE {
|
|
||||||
state BACKUP
|
|
||||||
interface eth0
|
|
||||||
virtual_router_id 55
|
|
||||||
priority 145
|
|
||||||
advert_int 1
|
|
||||||
unicast_src_ip 192.168.1.3
|
|
||||||
unicast_peer {
|
|
||||||
192.168.1.2
|
|
||||||
}
|
|
||||||
|
|
||||||
authentication {
|
|
||||||
auth_type PASS
|
|
||||||
auth_pass secret
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual_ipaddress {
|
|
||||||
192.168.1.4/24
|
|
||||||
}
|
|
||||||
|
|
||||||
track_script {
|
|
||||||
chk_ftl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# Place under /etc/keepalived/keepalived.conf on MASTER pihole
|
|
||||||
global_defs {
|
|
||||||
router_id pihole-dns-01
|
|
||||||
script_user root
|
|
||||||
enable_script_security
|
|
||||||
}
|
|
||||||
|
|
||||||
vrrp_script chk_ftl {
|
|
||||||
script "/usr/local/scripts/chk_ftl"
|
|
||||||
interval 1
|
|
||||||
weight -10
|
|
||||||
}
|
|
||||||
|
|
||||||
vrrp_instance PIHOLE {
|
|
||||||
state MASTER
|
|
||||||
interface eth0
|
|
||||||
virtual_router_id 55
|
|
||||||
priority 150
|
|
||||||
advert_int 1
|
|
||||||
unicast_src_ip 192.168.2.2
|
|
||||||
unicast_peer {
|
|
||||||
192.168.2.3
|
|
||||||
}
|
|
||||||
|
|
||||||
authentication {
|
|
||||||
auth_type PASS
|
|
||||||
auth_pass secret
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual_ipaddress {
|
|
||||||
192.168.2.4/24
|
|
||||||
}
|
|
||||||
|
|
||||||
track_script {
|
|
||||||
chk_ftl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Place under /etc/scripts for FTL Status check of keepalived
|
|
||||||
|
|
||||||
STATUS=$(ps ax | grep -v grep | grep pihole-FTL)
|
|
||||||
|
|
||||||
if [ "$STATUS" != "" ]
|
|
||||||
then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Name: cooler_skript
|
|
||||||
# Purpose: Anschluss eines Kuehlkoerpers und Temperatur Sensor
|
|
||||||
# GPIO-Library: RPi.GPIO 0.5.4
|
|
||||||
#
|
|
||||||
# Author: Felix Stern
|
|
||||||
# Website: www.tutorials-raspberrypi.de
|
|
||||||
#
|
|
||||||
# Created: 04.04.2014
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
#!/usr/bin/env python
|
|
||||||
import RPi.GPIO as GPIO
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
|
|
||||||
GPIO.setmode(GPIO.BCM)
|
|
||||||
GPIO.setwarnings(False)
|
|
||||||
|
|
||||||
IMPULS_PIN = 23 #Pin, der zum Transistor fuehrt
|
|
||||||
SLEEP_TIME = 30 #Alle wie viel Sekunden die Temperatur ueberprueft wird
|
|
||||||
MAX_CPU_TEMP = 40 #Ab welcher CPU Temperatur der Luefter sich drehen soll
|
|
||||||
MAX_SENSOR_TEMP = 30 #Ab welcher Temperatur im Gehaeuse der Luefter sich drehen soll
|
|
||||||
SENSOR_ID = '' #ID des Sonsors, BITTE ANPASSEN, falls kein Sensor vorhanden leer lassen
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_sensor_temperature():
|
|
||||||
try:
|
|
||||||
tempfile = open("/sys/bus/w1/devices/"+SENSOR_ID+"/w1_slave")
|
|
||||||
text = tempfile.read()
|
|
||||||
tempfile.close()
|
|
||||||
temperature_data = text.split()[-1]
|
|
||||||
temperature = float(temperature_data[2:])
|
|
||||||
temperature = temperature / 1000
|
|
||||||
return float(temperature)
|
|
||||||
except:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def get_cpu_temperature():
|
|
||||||
temp = os.popen('vcgencmd measure_temp').readline()
|
|
||||||
return float(temp.replace("temp=","").replace("'C\n",""))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
#Init
|
|
||||||
GPIO.setup(IMPULS_PIN, GPIO.OUT)
|
|
||||||
GPIO.output(IMPULS_PIN, False)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
cpu_temp = get_cpu_temperature()
|
|
||||||
sensor_temp = get_sensor_temperature()
|
|
||||||
if cpu_temp >= MAX_CPU_TEMP or sensor_temp >= MAX_SENSOR_TEMP :
|
|
||||||
GPIO.output(IMPULS_PIN, True)
|
|
||||||
else:
|
|
||||||
GPIO.output(IMPULS_PIN, False)
|
|
||||||
|
|
||||||
#print "gemessene CPU Temperatur:" + str(cpu_temp)
|
|
||||||
#print "gemessene Sensor Temperatur:" + str(sensor_temp)
|
|
||||||
|
|
||||||
time.sleep(SLEEP_TIME)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# (c) Christopher Münzer DB InfraGo Betriebszentrale Duisburg
|
|
||||||
|
|
||||||
USB_DEVICE="/dev/sda" # Ändern Sie dies zu Ihrem USB-Stick
|
|
||||||
OUTPUT_ISO="windows_isbpn_$(date +%Y%m%d).iso"
|
|
||||||
LOG="/tmp/log.txt"
|
|
||||||
|
|
||||||
touch $LOG
|
|
||||||
|
|
||||||
echo "1. Analysiere USB-Stick..." >> $LOG
|
|
||||||
sudo fdisk -l "$USB_DEVICE"
|
|
||||||
|
|
||||||
echo "2. Erstelle temporäre Verzeichnisse..." >> $LOG
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
mkdir -p "$TEMP_DIR"/{mount1,mount2,iso}
|
|
||||||
|
|
||||||
echo "3. Identifiziere Bootloader-Dateien..." >> $LOG
|
|
||||||
|
|
||||||
# Boot-Sektor sichern (für BIOS-Boot)
|
|
||||||
sudo dd if="$USB_DEVICE" of="$TEMP_DIR/bootsect.bin" bs=512 count=1 2>/dev/null
|
|
||||||
|
|
||||||
echo "4. Mounte und kopiere Partitionen..." >> $LOG
|
|
||||||
|
|
||||||
# Erste Partition mounten (normalerweise FAT32/EFI)
|
|
||||||
PARTITION_COUNT=$(sudo fdisk -l "$USB_DEVICE" | grep "^/dev" | wc -l)
|
|
||||||
|
|
||||||
if [ $PARTITION_COUNT -ge 1 ]; then
|
|
||||||
echo " - Kopiere Partition 1..." >> $LOG
|
|
||||||
sudo mount "${USB_DEVICE}1" "$TEMP_DIR/mount1" 2>/dev/null
|
|
||||||
if mountpoint -q "$TEMP_DIR/mount1"; then
|
|
||||||
sudo cp -r "$TEMP_DIR"/mount1/* "$TEMP_DIR/iso/" 2>/dev/null
|
|
||||||
sudo umount "$TEMP_DIR/mount1" 2>/dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $PARTITION_COUNT -ge 2 ]; then
|
|
||||||
echo " - Kopiere Partition 2..." >> $LOG
|
|
||||||
sudo mount "${USB_DEVICE}2" "$TEMP_DIR/mount2" 2>/dev/null
|
|
||||||
if mountpoint -q "$TEMP_DIR/mount2"; then
|
|
||||||
sudo cp -r "$TEMP_DIR"/mount2/* "$TEMP_DIR/iso/" 2>/dev/null
|
|
||||||
sudo umount "$TEMP_DIR/mount2" 2>/dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "5. Suche nach Bootloader-Dateien..." >> $LOG
|
|
||||||
# Typische Windows-Boot-Dateien
|
|
||||||
BOOT_FILES=(
|
|
||||||
"bootmgr"
|
|
||||||
"bootmgr.efi"
|
|
||||||
"efi/boot/bootx64.efi"
|
|
||||||
"efi/boot/bootia32.efi"
|
|
||||||
"efi/microsoft/boot/bootmgfw.efi"
|
|
||||||
"boot/bcd"
|
|
||||||
"boot/boot.sdi"
|
|
||||||
)
|
|
||||||
|
|
||||||
BOOT_IMAGE=""
|
|
||||||
for file in "${BOOT_FILES[@]}"; do
|
|
||||||
if [ -f "$TEMP_DIR/iso/$file" ]; then
|
|
||||||
echo " Gefunden: $file"
|
|
||||||
if [[ "$file" == *.efi ]] || [[ "$file" == *.bin ]]; then
|
|
||||||
BOOT_IMAGE="$file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "6. Erstelle bootfähige ISO..." >> $LOG
|
|
||||||
|
|
||||||
if [ -n "$BOOT_IMAGE" ]; then
|
|
||||||
echo " Verwende Boot-Image: $BOOT_IMAGE" >> $LOG
|
|
||||||
sudo genisoimage \
|
|
||||||
-b "$BOOT_IMAGE" \
|
|
||||||
-no-emul-boot \
|
|
||||||
-boot-load-size 8 \
|
|
||||||
-iso-level 3 \
|
|
||||||
-udf \
|
|
||||||
-allow-limited-size \
|
|
||||||
-J -l -D -N \
|
|
||||||
-joliet-long \
|
|
||||||
-relaxed-filenames \
|
|
||||||
-o "$OUTPUT_ISO" \
|
|
||||||
"$TEMP_DIR/iso"
|
|
||||||
else
|
|
||||||
echo " Kein Boot-Image gefunden, erstelle nicht-bootfähige ISO..." >> $LOG
|
|
||||||
sudo genisoimage \
|
|
||||||
-iso-level 3 \
|
|
||||||
-udf \
|
|
||||||
-allow-limited-size \
|
|
||||||
-J -l -D -N \
|
|
||||||
-joliet-lo ng \
|
|
||||||
-relaxed-filenames \
|
|
||||||
-o "$OUTPUT_ISO" \
|
|
||||||
"$TEMP_DIR/iso"
|
|
||||||
|
|
||||||
echo " Hinweis: ISO ist nicht bootfähig. Für bootfähige ISO müssen Sie:"
|
|
||||||
echo " 1. Windows ADK auf einem Windows-System verwenden"
|
|
||||||
echo " 2. Oder die originale Windows ISO mit Ihren Dateien neu erstellen"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "7. Aufräumen..." >> $LOG
|
|
||||||
sudo rm -rf "$TEMP_DIR"
|
|
||||||
|
|
||||||
echo "8. Prüfe ISO..." >> $LOG
|
|
||||||
if [ -f "$OUTPUT_ISO" ]; then
|
|
||||||
echo "Fertig! ISO erstellt: $OUTPUT_ISO" >> $LOG
|
|
||||||
echo "Größe: $(ls -lh "$OUTPUT_ISO" | awk '{print $5}')"
|
|
||||||
|
|
||||||
# Teste ISO-Struktur
|
|
||||||
echo "ISO-Struktur:"
|
|
||||||
isoinfo -i "$OUTPUT_ISO" -l 2>/dev/null | head -20 || \
|
|
||||||
xorriso -indev "$OUTPUT_ISO" -toc 2>/dev/null | head -20 || \
|
|
||||||
echo "Kann ISO nicht lesen, aber Datei wurde erstellt." >> $LOG
|
|
||||||
else
|
|
||||||
echo "FEHLER: ISO wurde nicht erstellt!" >> $LOG
|
|
||||||
fi
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# (c) Christopher Münzer DB InfraGo Betriebszentrale Duisburg
|
|
||||||
|
|
||||||
USB_DEVICE="/dev/sda"
|
|
||||||
OUTPUT_ISO="windows_$(date +%Y%m%d).iso"
|
|
||||||
|
|
||||||
echo "1. Analysiere USB-Stick..."
|
|
||||||
sudo fdisk -l "$USB_DEVICE"
|
|
||||||
|
|
||||||
echo "2. Erstelle temporäre Verzeichnisse..."
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
mkdir -p "$TEMP_DIR"/{mount1,mount2,iso}
|
|
||||||
|
|
||||||
echo "3. Kopiere Boot-Sektion..."
|
|
||||||
sudo dd if="$USB_DEVICE" of="$TEMP_DIR/bootsect.bin" bs=512 count=1
|
|
||||||
|
|
||||||
echo "4. Mounte und kopiere Partitionen..."
|
|
||||||
# Erste Partition (normalerweise FAT32/EFI)
|
|
||||||
sudo mount "${USB_DEVICE}1" "$TEMP_DIR/mount1" 2>/dev/null
|
|
||||||
sudo cp -r "$TEMP_DIR"/mount1/* "$TEMP_DIR/iso/" 2>/dev/null
|
|
||||||
|
|
||||||
# Zweite Partition (normalerweise NTFS/Installation)
|
|
||||||
sudo mount "${USB_DEVICE}2" "$TEMP_DIR/mount2" 2>/dev/null
|
|
||||||
sudo cp -r "$TEMP_DIR"/mount2/* "$TEMP_DIR/iso/" 2>/dev/null
|
|
||||||
|
|
||||||
echo "5. Erstelle bootfähige ISO..."
|
|
||||||
sudo genisoimage \
|
|
||||||
-b efi/microsoft/boot/efisys.bin \
|
|
||||||
-no-emul-boot \
|
|
||||||
-boot-load-size 8 \
|
|
||||||
-iso-level 3 \
|
|
||||||
-udf \
|
|
||||||
-allow-limited-size \
|
|
||||||
-J -l -D -N \
|
|
||||||
-joliet-long \
|
|
||||||
-relaxed-filenames \
|
|
||||||
-o "$OUTPUT_ISO" \
|
|
||||||
"$TEMP_DIR/iso"
|
|
||||||
|
|
||||||
echo "6. Aufräumen..."
|
|
||||||
sudo umount "$TEMP_DIR"/mount* 2>/dev/null
|
|
||||||
sudo rm -rf "$TEMP_DIR"
|
|
||||||
|
|
||||||
echo "Fertig! ISO erstellt: $OUTPUT_ISO"
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#(c) Christopher Münzer DB InfraGo Betriebszentrale Duisburg
|
|
||||||
|
|
||||||
clear
|
|
||||||
echo "Willkommen beim Tool für das bespielen des ISBP Installationssticks"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
echo "Auf welchem Gerät soll der Befehl ausgeführt werden?"
|
|
||||||
echo "a) /dev/sda"
|
|
||||||
echo "b) /dev/sdb"
|
|
||||||
echo -n "Ihre Wahl (a/b): "
|
|
||||||
|
|
||||||
read -r choice
|
|
||||||
|
|
||||||
case $choice in
|
|
||||||
a|A)
|
|
||||||
device="/dev/sda"
|
|
||||||
;;
|
|
||||||
b|B)
|
|
||||||
device="/dev/sdb"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Ungültige Eingabe!"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
IMAGE=/tmp/win_isbp_24_3_1_3.img
|
|
||||||
|
|
||||||
dd if="$IMAGE" of="$device" status=progress
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#(c)By CeMunz IT
|
|
||||||
#Script zum Sicheren löschen von Festplatten
|
|
||||||
|
|
||||||
clear
|
|
||||||
|
|
||||||
echo "Willkommen beil Löschungstool für Festplatten (HDDs)"
|
|
||||||
echo ""
|
|
||||||
echo "Es laufen insgesammt 2 Löschvorgänge durch!"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
FP= ls /dev/sd* | grep sd
|
|
||||||
echo ""
|
|
||||||
read -p "Bitte Festplatte wählen (a...g):" lp
|
|
||||||
echo "folgende Festplatte wird gelöscht:"
|
|
||||||
|
|
||||||
echo "/dev/sd$lp"
|
|
||||||
echo -n "Richtige Platte gewählt?(j/n): "
|
|
||||||
read -r choice
|
|
||||||
|
|
||||||
case $choice in
|
|
||||||
j|J)
|
|
||||||
echo "Festplatte wird gelöscht. NICHT VORZEITIG STOPPEN!"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Vorgang abgebrochen!"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Erster Vorgang"
|
|
||||||
|
|
||||||
# Setzen des Passwortes zum löschen
|
|
||||||
sudo hdparm --user-master u --security-set-pass Eins /dev/sd$lp > /dev/null
|
|
||||||
sudo hdparm --user-master u --security-erase-enhanced Eins /dev/sd$lp
|
|
||||||
|
|
||||||
echo "Zweiter Vorgang"
|
|
||||||
|
|
||||||
### In Bearbeitung!
|
|
||||||
### #sudo dd if=/dev/urandom of=/dev/sd$lp bs=4M status=progress conv=fdatasync
|
|
||||||
|
|
||||||
### #echo "Dritter Vorgang"
|
|
||||||
|
|
||||||
sudo dd if=/dev/zero of=/dev/sd$lp bs=1M status=progress conv=fdatasync
|
|
||||||
|
|
||||||
echo "Metadaten löschen:" # wipefs macht die Platte "sauber" von Metadaten für eine neue Nutzung
|
|
||||||
wipefs -a /dev/sd$lp
|
|
||||||
|
|
||||||
echo "Festplatte /dev/sd$lp erfolgtreich gelöscht!"
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Dieses Script ist für die Aktuallisierung vom Hivellominer Node
|
|
||||||
#
|
|
||||||
# Eine Überarbeitung ist zulässig, muss aber dann wieder zur Verfügung gestellt werden
|
|
||||||
#
|
|
||||||
# Version 1.2
|
|
||||||
#
|
|
||||||
# (c)2025 CeMunzIT Christopher Münzer
|
|
||||||
|
|
||||||
clear
|
|
||||||
|
|
||||||
dir="/opt/hivello/"
|
|
||||||
hv="hivello"
|
|
||||||
hvd="$hv.deb"
|
|
||||||
|
|
||||||
if [ -d "$dir" ]; then
|
|
||||||
echo "Verzeichniss vorhanden"
|
|
||||||
else
|
|
||||||
echo "Verzeichniss wird erstellt"
|
|
||||||
if ! mkdir -p "$dir"; then
|
|
||||||
echo "Konnte Verzeichnis nicht erstellen" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
echo "Verzeichnis erfolgreich erstellt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $dir
|
|
||||||
|
|
||||||
if [ -f "$hvd" ]; then
|
|
||||||
echo "$hv vohanden und wird deinstalliert"
|
|
||||||
sleep 4
|
|
||||||
dpkg -r $hv
|
|
||||||
echo "$hvd Datei wird gelöscht"
|
|
||||||
sleep 4
|
|
||||||
rm -rf $hvd
|
|
||||||
else
|
|
||||||
echo "Datei ist nicht vorhanden und wird gedownloadet"
|
|
||||||
fi
|
|
||||||
|
|
||||||
wget https://download.hivello.services/linux/hivello.deb
|
|
||||||
|
|
||||||
sleep 4
|
|
||||||
|
|
||||||
cd $dir
|
|
||||||
|
|
||||||
echo "neue Datei wird Installiert"
|
|
||||||
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
dpkg -i $hvd
|
|
||||||
|
|
||||||
echo "beendet"
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
OWM_API_KEY=ea645349e2fbb2ff573104bdd6763604
|
|
||||||
DB_USER=root
|
|
||||||
DB_PASSWORD=dein_db_passwort
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_NAME=weather_db
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
**1. Voraussetzungen installieren**
|
|
||||||
|
|
||||||
API Key auf openweathermap.org generieren
|
|
||||||
|
|
||||||
```
|
|
||||||
pip install requests mariadb python-dotenv
|
|
||||||
```
|
|
||||||
|
|
||||||
**2. Datenbank Vorbereiten**
|
|
||||||
|
|
||||||
```
|
|
||||||
CREATE DATABASE weather_db;
|
|
||||||
|
|
||||||
USE weather_db;
|
|
||||||
|
|
||||||
CREATE TABLE weather_data (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
city VARCHAR(100) NOT NULL,
|
|
||||||
country VARCHAR(10),
|
|
||||||
temperature FLOAT,
|
|
||||||
feels_like FLOAT,
|
|
||||||
humidity INT,
|
|
||||||
pressure INT,
|
|
||||||
wind_speed FLOAT,
|
|
||||||
description VARCHAR(255),
|
|
||||||
recorded_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
**3. Script und .env Datei ablegen und bearbeiten**
|
|
||||||
|
|
||||||
**4. Cronjob**
|
|
||||||
```
|
|
||||||
0 * * * * /usr/bin/python3 /pfad/zum/weather_script.py
|
|
||||||
```
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
import requests
|
|
||||||
import mariadb
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from datetime import datetime
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
# Umgebungsvariablen aus .env laden
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
# --- Konfiguration ---
|
|
||||||
API_KEY = os.getenv("OWM_API_KEY")
|
|
||||||
CITY = "Berlin"
|
|
||||||
UNITS = "metric" # metric = Celsius, imperial = Fahrenheit
|
|
||||||
|
|
||||||
DB_CONFIG = {
|
|
||||||
"user": os.getenv("DB_USER", "root"),
|
|
||||||
"password": os.getenv("DB_PASSWORD", ""),
|
|
||||||
"host": os.getenv("DB_HOST", "127.0.0.1"),
|
|
||||||
"port": int(os.getenv("DB_PORT", 3306)),
|
|
||||||
"database": os.getenv("DB_NAME", "weather_db"),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_weather(city):
|
|
||||||
"""Ruft Wetterdaten von der OpenWeatherMap-API ab."""
|
|
||||||
url = "https://api.openweathermap.org/data/2.5/weather"
|
|
||||||
params = {
|
|
||||||
"q": city,
|
|
||||||
"appid": API_KEY,
|
|
||||||
"units": UNITS,
|
|
||||||
"lang": "de",
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = requests.get(url, params=params, timeout=10)
|
|
||||||
response.raise_for_status()
|
|
||||||
return response.json()
|
|
||||||
except requests.exceptions.RequestException as e:
|
|
||||||
print(f"Fehler beim Abrufen der Wetterdaten: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def parse_weather(data):
|
|
||||||
"""Extrahiert die relevanten Felder aus der API-Antwort."""
|
|
||||||
return {
|
|
||||||
"city": data["name"],
|
|
||||||
"country": data["sys"].get("country", ""),
|
|
||||||
"temperature": data["main"]["temp"],
|
|
||||||
"feels_like": data["main"]["feels_like"],
|
|
||||||
"humidity": data["main"]["humidity"],
|
|
||||||
"pressure": data["main"]["pressure"],
|
|
||||||
"wind_speed": data["wind"]["speed"],
|
|
||||||
"description": data["weather"][0]["description"],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def save_to_db(weather):
|
|
||||||
"""Speichert die Wetterdaten in der MariaDB."""
|
|
||||||
try:
|
|
||||||
conn = mariadb.connect(**DB_CONFIG)
|
|
||||||
except mariadb.Error as e:
|
|
||||||
print(f"Fehler bei der DB-Verbindung: {e}")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
sql = """
|
|
||||||
INSERT INTO weather_data
|
|
||||||
(city, country, temperature, feels_like, humidity,
|
|
||||||
pressure, wind_speed, description, recorded_at)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
||||||
"""
|
|
||||||
values = (
|
|
||||||
weather["city"],
|
|
||||||
weather["country"],
|
|
||||||
weather["temperature"],
|
|
||||||
weather["feels_like"],
|
|
||||||
weather["humidity"],
|
|
||||||
weather["pressure"],
|
|
||||||
weather["wind_speed"],
|
|
||||||
weather["description"],
|
|
||||||
datetime.now(),
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
cursor.execute(sql, values)
|
|
||||||
conn.commit()
|
|
||||||
print(f"Daten gespeichert (ID: {cursor.lastrowid})")
|
|
||||||
except mariadb.Error as e:
|
|
||||||
print(f"Fehler beim Speichern: {e}")
|
|
||||||
conn.rollback()
|
|
||||||
finally:
|
|
||||||
cursor.close()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
if not API_KEY:
|
|
||||||
print("Fehler: OWM_API_KEY nicht gesetzt. Bitte in .env eintragen.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print(f"Rufe Wetterdaten für '{CITY}' ab...")
|
|
||||||
data = fetch_weather(CITY)
|
|
||||||
|
|
||||||
if data:
|
|
||||||
weather = parse_weather(data)
|
|
||||||
print(f"Temperatur: {weather['temperature']}°C, "
|
|
||||||
f"{weather['description']}")
|
|
||||||
save_to_db(weather)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "==== WIREGUARD CONTROL ===="
|
|
||||||
echo "1) Start Wireguard"
|
|
||||||
echo "2) Stop Wireguard"
|
|
||||||
echo "3) Status Wireguard"
|
|
||||||
echo "4) Exit"
|
|
||||||
|
|
||||||
read -p "Wähle Option 1-4 " choice
|
|
||||||
|
|
||||||
|
|
||||||
case "$choice" in
|
|
||||||
1)
|
|
||||||
sudo wg-quick up wg0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
sudo wg-quick down wg0
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
sudo wg show
|
|
||||||
;;
|
|
||||||
|
|
||||||
4)
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Ungültige auswahl"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
read -p "Drücke Enter um fortzufahren"
|
|
||||||
Reference in New Issue
Block a user