pinebook-tests/connect-to-wifi/main.go

45 lines
866 B
Go
Raw Normal View History

package main
// import "os"
import "log"
import "time"
import "fmt"
/*
import "reflect"
*/
import "git.wit.com/jcarr/shell"
func dhclient() {
shell.Run("systemctl stop NetworkManager.service")
shell.Run("systemctl disable NetworkManager.service")
shell.Run("systemctl stop wpa_supplicant.service")
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")
for {
fmt.Print(" should check progress here")
time.Sleep(20000 * time.Millisecond)
}
}
func main() {
parseConfig()
go dhclient()
for {
time.Sleep(1000 * 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")
}