└── shutdown.sh /shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script is called by my PiJuice HAT when power is lost to the UPS HAT if no WiFi connection is available when the script runs it will do everything apart from upload 4 | # the upload will happen the next time it loses power and internet is available 5 | # 6 | # Credit to ElKentaro for the Upload2Wigle script available here https://github.com/elkentaro/upload2wigle 7 | # Paths are relative to my Pi setup please feel free to either create the directory structure as per the below or amend them accordingly 8 | # To cheat and make the directories that I use below run the following: 9 | # sudo mkdir /home/pi/wardriving 10 | # sudo mkdir /home/pi/wardriving/processed 11 | # sudo mkdir /home/pi/wardriving/2wigle 12 | # sudo mkdir /home/pi/wardriving/2wigle/uploaded 13 | # 14 | 15 | # First thing we'll do is stop kismet 16 | sudo systemctl stop kismet 17 | 18 | # Next we'll process our kismet files (clean up DBs and get the data out of the DBs ready for Wigle) 19 | 20 | FILES="/home/pi/wardriving/*.kismet" 21 | for f in $FILES 22 | do 23 | kismetdb_clean -i "$f" 24 | kismetdb_to_wiglecsv -i "$f" -o "$f".csv 25 | 26 | sudo mv "$f" /home/pi/wardriving/processed/ 27 | 28 | done 29 | # Now let's move our csv files into our 2wigle folder 30 | 31 | sudo mv /home/pi/wardriving/*.csv /home/pi/wardriving/2wigle/ 32 | 33 | # Time to upload them to Wigle! 34 | 35 | FILES2GO="/home/pi/wardriving/2wigle/*.csv" 36 | 37 | for f in $FILES2GO 38 | 39 | do 40 | APIName=**APINAMEHERE** 41 | APIToken=**APITOKENHERE** 42 | curl -X POST "https://api.wigle.net/api/v2/file/upload" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@$f;type=text/csv" -F "donate=on" -i -H 'Accept:application/json' -u $APIName:$APIToken --basic && mv $f /home/pi/wardriving/2wigle/uploaded 43 | done 44 | 45 | # Finished uploading time to shutdown! 46 | 47 | sudo shutdown now 48 | --------------------------------------------------------------------------------