Raspberry Pi
Momentan gibt es am Raspberry Pi mehr als ein Dutzend Projekte. Ich betreibe zurzeit nur zwei: Motion und Nextcloud.
Motion:
Eine „geniale“ Entwicklung – für ca. 50 € (so kostet ein Raspberry Pi) haben Sie ein tolles Überwachungssystem, egal ob für Zuhause oder für Ihre Firma. Mit einem kleinen Skript auf dem RasPi und einer Cloud (ich nutze Dropbox) haben Sie AVI‑Dateien (kleine Videodateien) direkt in der Cloud. Das heißt: Alles, was sich vor Ihrer Webcam bewegt hat, wird zuerst auf dem RasPi gespeichert und dann je nach Plan (z. B. per crontab) in die Cloud übertragen.
Falls Sie Interesse daran haben, kann ich gerne meine Erfahrungen (und Skripte) mit Ihnen teilen.
Nextcloud:
Nextcloud habe ich leider nur in meinem privaten LAN getestet (also noch nicht im Internet).
-------------
Netzwerk am Raspi einrichten:
# sudo iwlist wlan0 scan | grep ESSID
ESSID:"FRITZ!Box 12345"
ESSID:"XYZ"
ESSID:"WLAN-12345"
..................
-In der Liste, die dir ausgegeben wird, finde deinen Router und trage dann die Informationen in die Datei /etc/wpa_supplicant/wpa_supplicant.conf ein, etwa so:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid=""FRITZ!Box 12345""
psk="123456789....."
}
Es kann passieren, dass das WLAN nicht automatisch hochfährt. Dann kannst du folgende Befehle auf deinem Raspberry Pi ausführen:
# sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf# sudo systemctl restart dhcpcd
Prüf mal, ob dein raspi über WLAN erreichbar ist: ping 192.xxxxxxxxxx
oder direkt am raspi:
# iwconfig wlan0
IEEE 802.11 ESSID:"FRITZ!Box 12345"
Mode:Managed Frequency:2.462 GHz Access Point: xxxxxxxxxxxxxx
Bit Rate=72.2 Mb/s Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=55/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:9 Invalid misc:0 Missed beacon:0# sudo wpa_cli -i wlan0 status
bssid=xxxxxxxxxxxxxx
freq=2462
ssid=FRITZ!Box 12345
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.xxxxxxxx
p2p_device_address=123456789xxxxxxxxxxx
address=b8:27:eb:c0:2a:c6
uuid=123456789xxxxxxxxxxx
Du kannst auch folgende Befehle nutzen, um die IP-Adresse deines WLANs zu überprüfen:
# ifconfig wlan0
# ip addr show wlan0
Außerdem gibt es noch eine Reihe netzwerkmäßiger Befehle:
sudo systemctl status wpa_supplicant.service
sudo systemctl restart networking.service
.........................
# sudo systemctl restart dhcpcd
# sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
# sudo dhclient wlan0
# sudo iwlist wlan0 scan
# dmesg | grep wlan0
# sudo systemctl restart wpa_supplicant.service
.......................
# iwconfig wlan0
# sudo wpa_cli -i wlan0 status
# dmesg | grep wlan0
# journalctl -xe | grep wpa_supplicantv
# sudo ifconfig wlan0 <deine_IP> netmask <deine_Netzmaske> up
# sudo systemctl restart wpa_supplicant.service
# nmcli dev wifi list
Staus deine WLAN am Raspi prüfst du mittels Befehlen:
# ifconfig wlan0
# iwconfig
# sudo systemctl status wpa_supplicant.service
Motion Server am Raspberry Pi:
crontab -l
*/10 * * * * /usr/local/bin/target_leeren
*/55 * * * * /usr/local/bin/uebertrage_motion_dateien
@reboot sleep 180 && systemctl isolate multi-user.target
@reboot sleep 60 && /usr/local/bin/ob_motin_gestartet
@reboot sleep 60 && /usr/local/bin/check_wlan
--------------------------
cat /usr/local/bin/target_leeren
#!/bin/bash
if [ `du /media/pi/USB-STICK/motion/ | awk '{print $1}'` -gt 100000 ];
then
for A in `ls -lrt /media/pi/USB-STICK/motion/ | awk '{print $9}' | head -1900`
do
rm /media/pi/USB-STICK/motion/$A
done
else echo OK; fi
.....................
cat /usr/local/bin/uebertrage_motion_dateien
#!/bin/bash
cd /media/pi/USB-STICK/motion/;
for A in `ls -rtl *avi | tail | awk '{print $9}'`;
do dropbox_uploader.sh upload `pwd`/$A ./Das_Verzeichnis_im_Internet/;
done
.....................
der Befehl systemctl isolate multi-user.target fährt grafische Konsole am raspi herunter
.....................
cat /usr/local/bin/ob_motin_gestartet
if [ `ps -ef | grep motion | grep -v grep | wc -l` -ne 0 ];
then echo "OK"
else
motion &
fi
.....................
cat /usr/local/bin/check_wlan
if [ `ifconfig wlan0 | grep "192.168.xxxxx" | wc -l` -eq 1 ]
then
echo OK
else
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf;
sudo dhclient wlan0;
sleep 60 && sudo systemctl restart dhcpcd
fi