From 93425b35779aceedcc34e19ad7db5d4a6607e975 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Wed, 2 Nov 2016 20:42:56 +0000
Subject: [PATCH] Check if wifi adaptors exist

---
 src/freedombone-controlpanel | 6 ++++++
 src/freedombone-utils-wifi   | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel
index 4187d3020..52e677de3 100755
--- a/src/freedombone-controlpanel
+++ b/src/freedombone-controlpanel
@@ -1720,6 +1720,12 @@ function wifi_enable {
 }
 
 function menu_wifi {
+    if [[ "$(wifi_exists)" == "0" ]]; then
+        dialog --title $"Wifi" \
+               --msgbox $"No wifi adaptors were detected" 6 40
+        return
+    fi
+
     while true
     do
         status_str=$'Wifi OFF'
diff --git a/src/freedombone-utils-wifi b/src/freedombone-utils-wifi
index 08b07c441..086d0c3aa 100755
--- a/src/freedombone-utils-wifi
+++ b/src/freedombone-utils-wifi
@@ -573,6 +573,14 @@ function count_wlan {
     echo $ctr
 }
 
+function wifi_exists {
+    if grep -q "wlan" /proc/net/dev; then
+        echo "1"
+    else
+        echo "0"
+    fi
+}
+
 function remove_wifi_startup_script {
     remove_config_param "WIFI_INTERFACE"
     systemd_file=/etc/systemd/system/wifistart.service
-- 
GitLab