make connect-to-wifi do only that

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-04-24 01:21:12 -07:00
parent 11ecd5e794
commit f0e87cc968
1 changed files with 18 additions and 7 deletions

View File

@ -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
}