From 115e846da86f26f0ac4742354498ff67da2946fb Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Sat, 22 Oct 2016 16:11:57 +0100
Subject: [PATCH] Sleep on nodown

---
 src/freedombone-image-customise | 3 ++-
 src/freedombone-utils-wifi      | 3 ++-
 src/freedombone-wifi            | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise
index f42382d2e..44aa220a9 100755
--- a/src/freedombone-image-customise
+++ b/src/freedombone-image-customise
@@ -413,13 +413,14 @@ EOF
     echo "                echo 'Description=WifiStartup (Start wifi networking)' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'After=syslog.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'After=network.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
+    echo "                echo 'After=remote-fs.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo '' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo '[Service]' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'Type=simple' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'User=root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'Group=root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'WorkingDirectory=/root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
-    echo "                echo 'ExecStart=/usr/local/bin/freedombone-wifi' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
+    echo "                echo 'ExecStart=/usr/local/bin/freedombone-wifi --nodown y' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo '' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo '[Install]' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
     echo "                echo 'WantedBy=multi-user.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
diff --git a/src/freedombone-utils-wifi b/src/freedombone-utils-wifi
index 56ccb10c3..6723626c9 100755
--- a/src/freedombone-utils-wifi
+++ b/src/freedombone-utils-wifi
@@ -555,13 +555,14 @@ function create_wifi_startup_script {
     echo 'Description=WifiStartup (Start wifi networking)' >> $systemd_file
     echo 'After=syslog.target' >> $systemd_file
     echo 'After=network.target' >> $systemd_file
+    echo 'After=remote-fs.target' >> $systemd_file
     echo '' >> $systemd_file
     echo '[Service]' >> $systemd_file
     echo 'Type=simple' >> $systemd_file
     echo 'User=root' >> $systemd_file
     echo 'Group=root' >> $systemd_file
     echo 'WorkingDirectory=/root' >> $systemd_file
-    echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi" >> $systemd_file
+    echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi --nodown y" >> $systemd_file
     echo '' >> $systemd_file
     echo '[Install]' >> $systemd_file
     echo 'WantedBy=multi-user.target' >> $systemd_file
diff --git a/src/freedombone-wifi b/src/freedombone-wifi
index fe4c753b0..505c50805 100755
--- a/src/freedombone-wifi
+++ b/src/freedombone-wifi
@@ -141,6 +141,8 @@ if [ ! ${wifi_interface_specified} ]; then
     if [ ! $NODOWN ]; then
        wpa_action ${WIFI_INTERFACE} stop
        wpa_cli -i ${WIFI_INTERFACE} terminate
+    else
+        sleep 5
     fi
     update_wifi_adaptors
     if [ ! $IFACE ]; then
-- 
GitLab