Raspberry Pi: Wie kann der Kismet-Server sauber rauf und runter gefahren werden zum WarWalking (WarDriving)?

Wenn ein Kismet-Server auf dem Raspberry Pi läuft, muss der Server sauber rauf und runter gefahren werden, sonst werden die *NETXML Dateien wegen einem fehlenden sync nicht vollständig auf die SD-Karte geschrieben. Das Problem ist aber, wie kann der Raspberry Pi eingerichtet werden, so das der gpsd und Kismet automatisch hoch und auch sauber wieder runter fahren, ohne das ein Bildschirm bzw. Konsole angeschlossen wird? Und wie kann vom GPS Empfänger die Systemzeit gesetzt werden, da der Raspberry Pi ja keine Systemuhr hat und es beim WarWalking kein Internet mit NTP gibt ?

Die Lösung des Problems wird in dieser Anleitung beschrieben.

Wir brauchen ein Script zum automatischen hochfahren und ein Script das auf einen Tastendruck wartet.

Also zuerst ein autostart Verzeichnis erstellen und die beiden unten angegebenen Scripte in der neuesten Version laden:

mkdir autostart
cd autostart
wget https://github.com/IT-Berater/tw-scripte/blob/master/start-gps.sh
wget https://github.com/IT-Berater/tw-scripte/blob/master/warte.py
chmod +x start-gps.sh
chmod +x warte.py

Dann wie hier schon mal beschrieben das start-gps.sh automatisch starten lassen.

Hier das start-gps.sh Script welches per crontab automatisch nach dem anschalten des Raspberry Pis startet:

#!/bin/bash

#
# Dies start-gps.sh Script soll alles starten was für das wardrive nötig ist.
#
# 14.02.15 Thomas Wenzlaff
#
# 1. gpsd starten
# 2. Zeit von GPSD ermittelt und setzen
# 3. Kismet Server starten
# 4. Warten auf Tastendruck warten.py
# 5. LED blinken
# 6. Kismet sauber runterfahren
# 7. gpsd runterfahren
# 8. System runterfahren
#
# (C) 2015 Thomas Wenzlaff http://www.wenzlaff.de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see {http://www.gnu.org/licenses/}.
#
##############################################################################
echo 'Starte start-gps.sh Script ...'
killall gpsd
killall kismet_server

echo 'Starte gpsd Dämon im Hintergrund ...'
/etc/init.d/gpsd start
echo 'gpsd gestartet'

echo 'Warte bis GPS bereit ...'
/usr/bin/gpspipe -l -w -n 10 | grep -qm 1 '"mode":3'

echo 'Parse die aktuelle UTC Zeit von gpsd Ausgabe ...'
UTCDATE=`/usr/bin/gpspipe -w -n 10 | grep -m 1 "TPV" | sed -r 's/.*"time":"([^"]*)".*/\1/' | sed -e 's/^\(.\{10\}\)T\(.\{8\}\).*/\1 \2/'`

echo 'Setzt die aktuelle Systemzeit des Raspberry Pi mit $UTCDATE'
date -u -s "$UTCDATE"

echo 'Starte den Kismet Server im Hintergrund ...'
kismet_server --daemonize
echo 'Kismet Server gestartet'

echo 'warte.py starten'
echo 'Warte auf längeren Tastendruck bis die LED blinkt, zum sauberen runterfahren des Raspberry Pi ...'
/root/autostart/warte.py
echo 'warte.py beendet'

echo 'Warte bis der Kismet Server runtergefahren ist ...'
/usr/bin/pkill kismet_server
# warten bis Kismet seine Dateien gespeichert hat
/usr/bin/pgrep kismet
while [ $? = 0 ]
do
/bin/sleep 1
/usr/bin/pgrep kismet
done
echo 'OK, der Kismet Server ist sauber beendet.'

echo 'System sauber runterfahren ...'
/usr/bin/pkill gpsd
/bin/sleep 5
echo 'Starte nun shutdown now. Der Raspberry Pi kann gleich von der Stromversorgung getrennt werden.'
sudo shutdown now

Das warte.py Script wartet auf einen Tastendruck und blinkt dann 10 mal und beendet sich.
Der Taster ist an Pin 11 und die LED an Pin 7 mit einem oder zwei Vorwiederständen angeschlossen.

#!/usr/bin/python
# coding=ISO-8859-1

# warte.py Script
#
# Thomas Wenzlaff (c) 2015 www.wenzlaff.info
#
# Dieses Script wartet bis die Taste einmal gedrückt wird und dann
# wird als Bestätigung die LED 10 mal blinken.
#
# (C) 2015 Thomas Wenzlaff http://www.wenzlaff.de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see {http://www.gnu.org/licenses/}.
#
##############################################################################
import RPi.GPIO as GPIO
import time

SCHALTER = 11
LED = 7

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED, GPIO.OUT)
GPIO.setup(SCHALTER, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def blink( anzahl ):
 "Methode blinkt so oft wie anzahl"
 i = 0
 while (i < anzahl):
   GPIO.output(LED, True)
   time.sleep(0.1)
   GPIO.output(LED, False)
   time.sleep(0.1)
   i = i + 1


print "Start warte.py um %s Warte nun auf Tastendruck..." % time.ctime()

while True:
	input_state = GPIO.input(SCHALTER)
	time.sleep(2)
	if input_state == False:
		print "Taste wurde gedrückt"
		print "10 mal blinken ..."
 		blink(10)
		break

print "Das warten.py Script ist nun um %s zu Ende" % time.ctime()

Wer noch Details wissen will, einfach ein Kommentar und ein Like ;-) hinterlassen.

Ähnliche Artikel:

  1. Raspberry Pi: Wardriving (Warwalking) Kismet netxml Dateien visualisieren mit Google Earth
  2. Raspberry Pi: Wie kann eine automatische Scriptausführung nach einem reboot eingerichtet werden?
  3. Raspberry Pi Wardrive: Kismet compilieren und WLANs auf Google anzeigen

wallpaper-1019588
Final Fantasy XII – Brettspiel zum PS2-Klassiker angekündigt
wallpaper-1019588
Super Nintendo World – „Donkey Kong Country“-Eröffnung verschoben
wallpaper-1019588
Pokémon Karmesin und Purpur – Neues Tera-Raid-Event am Wochenende
wallpaper-1019588
Sonic Dream Team – Sega veröffentlicht zweites Inhaltsupdate