2019-04-08 18:43:02 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
// import "os"
|
|
|
|
import "log"
|
|
|
|
import "time"
|
|
|
|
import "fmt"
|
2019-04-09 16:53:40 -05:00
|
|
|
/*
|
2019-04-08 18:43:02 -05:00
|
|
|
import "reflect"
|
|
|
|
*/
|
|
|
|
|
|
|
|
import "git.wit.com/jcarr/shell"
|
|
|
|
|
2019-04-08 19:05:16 -05:00
|
|
|
func dhclient() {
|
2019-04-08 18:43:02 -05:00
|
|
|
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)
|
2019-04-08 19:05:16 -05:00
|
|
|
|
|
|
|
log.Println("wait for wpa_supplicant, then run dhclient")
|
|
|
|
shell.Run("sleep 20")
|
|
|
|
shell.Run("dhclient wlan0")
|
2019-04-08 18:43:02 -05:00
|
|
|
|
|
|
|
for {
|
2019-04-09 16:53:40 -05:00
|
|
|
fmt.Print(" should check progress here")
|
2019-04-09 16:42:21 -05:00
|
|
|
time.Sleep(20000 * time.Millisecond)
|
2019-04-08 18:43:02 -05:00
|
|
|
}
|
|
|
|
}
|
2019-04-08 19:05:16 -05:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
parseConfig()
|
|
|
|
|
2019-04-08 20:31:19 -05:00
|
|
|
go dhclient()
|
|
|
|
|
|
|
|
for {
|
|
|
|
time.Sleep(1000 * time.Millisecond)
|
2019-04-09 16:36:09 -05:00
|
|
|
ping := shell.Run("ping -c 1 git.wit.com")
|
2019-04-08 20:31:19 -05:00
|
|
|
log.Println("ping returned ", ping)
|
|
|
|
if (ping == 0) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shell.Run("/root/go/bin/get-image")
|
2019-04-08 19:05:16 -05:00
|
|
|
}
|