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

45 lines
898 B
Go

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 {
log.Println("need to check the status of wpa_supplicant and dhclient here")
time.Sleep(1000 * time.Millisecond)
}
}
func main() {
parseConfig()
go dhclient()
for {
time.Sleep(1000 * time.Millisecond)
ping := shell.Run("ping -c 1 localhost")
log.Println("ping returned ", ping)
if (ping == 0) {
break
}
}
shell.Run("/root/go/bin/get-image")
}