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

35 lines
725 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(5000 * time.Millisecond) // check every few seconds
}
}
func main() {
parseConfig()
dhclient()
}