From f0e87cc96864b3d2ab95994bd84f531c58670372 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 24 Apr 2019 01:21:12 -0700 Subject: [PATCH] make connect-to-wifi do only that Signed-off-by: Jeff Carr --- connect-to-wifi/main.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/connect-to-wifi/main.go b/connect-to-wifi/main.go index 2331067..794b48a 100644 --- a/connect-to-wifi/main.go +++ b/connect-to-wifi/main.go @@ -15,16 +15,17 @@ func dhclient() { shell.Run("systemctl stop NetworkManager.service") shell.Run("systemctl disable NetworkManager.service") shell.Run("systemctl stop wpa_supplicant.service") + shell.Run("killall wpa_supplicant") go shell.Daemon("wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant.conf", 1000 * time.Millisecond) - log.Println("wait for wpa_supplicant, then run dhclient") - shell.Run("sleep 20") - shell.Run("dhclient wlan0") + log.Println("it for wpa_supplicant, then run dhclient") for { - fmt.Println(" running") - time.Sleep(2000 * time.Millisecond) + fmt.Println("running wpa_supplicant in the background") + fmt.Println("need to figure out how to talk to it to see it's status") + shell.Run("ifconfig wlan0") + time.Sleep(5000 * time.Millisecond) filename := "/tmp/wit-install-done" if _, err := os.Stat(filename); !os.IsNotExist(err) { // log.Println("filename", filename, "does exist") @@ -38,13 +39,23 @@ func main() { go dhclient() + shell.Run("sleep 20") + shell.Run("dhclient wlan0") + for { - time.Sleep(1000 * time.Millisecond) + time.Sleep(10000 * time.Millisecond) ping := shell.Run("ping -c 1 git.wit.com") log.Println("ping returned ", ping) if (ping == 0) { break } } - shell.Run("/root/go/bin/get-image") + + log.Println("MACHINE WIFI IS WORKING") + log.Println("MACHINE WIFI IS WORKING") + log.Println("MACHINE WIFI IS WORKING") + log.Println("MACHINE WIFI IS WORKING") + log.Println("MACHINE WIFI IS WORKING") + + shell.Run("sleep 3600") // force it to bomb after 1 hour so I can debug what to do }