diff --git a/get-image/main.go b/get-image/main.go index 47b9b96..47f29ee 100644 --- a/get-image/main.go +++ b/get-image/main.go @@ -21,7 +21,7 @@ func main() { log.Println("device /dev/mmcblk0p2 exists") } else { log.Println("device /dev/mmcblk0p2 does not exist") - // fail() + fail() } shell.Run("mount /dev/mmcblk0p2 /home/factory") @@ -29,27 +29,22 @@ func main() { imagename := "factory-2019-01-20" fullname := "/home/factory/" + imagename - if _, err := os.Stat(fullname); !os.IsNotExist(err) { + // if the image does not exist, try to wget it + if _, err := os.Stat(fullname); os.IsNotExist(err) { log.Println("filename", fullname, "does not exist") shell.Run("cd /home/factory") shell.Run("wget -c " + "http://fire.lab.wit.com/factory/" + imagename) } + if _, err := os.Stat(fullname); !os.IsNotExist(err) { log.Println("filename", fullname, "exists. dd here") shell.Run("dd " + fullname + " of=/dev/mmcblk2 bs=1M status=progress oflag=sync") + succeeded() } else { log.Println("filename", fullname, "does not exist") fail() } - // wget -c http://fire.lab.wit.com/factory/ -/* -echo dd if=/home/factory/emmc.img.armbian of=/dev/mmcblk2 -dd if=/home/factory/emmc.img.armbian of=/dev/mmcblk2 bs=1M status=progress oflag=sync - -dialog --ascii-lines --msgbox "Flash Image Completed!" 10 70 -*/ - } func fail () { @@ -83,5 +78,8 @@ func succeeded () { log.Println("") log.Println("") + // try executing this from golang to see what happens + // dialog --ascii-lines --msgbox "Flash Image Completed!" 10 70 + os.Exit(0) } diff --git a/rc.local b/rc.local index 0a8bcee..044509b 100755 --- a/rc.local +++ b/rc.local @@ -12,6 +12,15 @@ echo STARTING PINEBOOK IMAGING IN 5 SECONDS echo echo CONTROL-C TO STOP echo + +echo +echo Kill off network manager and wpa_supplicant +echo + +systemctl stop NetworkManager.service +systemctl disable NetworkManager.service +systemctl stop wpa_supplicant.service + echo Connecting to wifi network WIT Public 2 killall wpa_supplicant ifconfig wlan0 up