CZI_presence_detector/scanner/scan.sh

48 lines
924 B
Bash
Raw Normal View History

2023-08-12 15:36:29 +02:00
#!/bin/bash
2023-08-12 17:23:33 +02:00
adapter=wlan0
conn_test_url=http://www.google.com
restart_network() {
systemctl restart wpa_supplicant
}
2023-08-12 15:36:29 +02:00
# Check for root privileges
if [ "$(id -u)" != "0" ]
then
>&2 echo "Quitting, this script has to be run as root!"
exit 1
fi
# Activate Monitor mode
trackerjacker --monitor-mode-on -i $adapter
# Run scan
2023-08-12 20:26:35 +02:00
timeout 60 trackerjacker -i $adapter --map
2023-08-12 15:36:29 +02:00
# Deactivate Monitor mode
2023-08-12 20:15:43 +02:00
trackerjacker --monitor-mode-off -i $adapter
2023-08-12 15:36:29 +02:00
# Test network & try to restart if it fails
for i in 1 2 3 4 5
do
sleep 10
wget -q --spider $conn_test_url && break
# no internet connection
echo "No internet - restarting network"
restart_network
done
# Network restarted up to 5 times, last test for connectivity
wget -q --spider $conn_test_url
if [ $? -eq 0 ]; then
# Filter & upload results
python upload.py
else
echo "ERROR: no network connection"
fi
2023-08-12 15:36:29 +02:00
# Remove old scan results
rm wifi_map.yaml