try to wget the image if it doesn't exist
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b2f4f6b9f5
commit
3869749fe2
|
@ -1,10 +1,10 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
import "os"
|
||||
import "log"
|
||||
/*
|
||||
import "fmt"
|
||||
import "reflect"
|
||||
import "os"
|
||||
*/
|
||||
|
||||
import "git.wit.com/jcarr/shell"
|
||||
|
@ -12,25 +12,76 @@ import "git.wit.com/jcarr/shell"
|
|||
func main() {
|
||||
parseConfig()
|
||||
|
||||
if _, err := os.Stat("/home/factory"); !os.IsNotExist(err) {
|
||||
} else {
|
||||
shell.Run("mkdir /home/factory")
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/dev/mmcblk0p2"); !os.IsNotExist(err) {
|
||||
log.Println("device /dev/mmcblk0p2 exists")
|
||||
} else {
|
||||
log.Println("device /dev/mmcblk0p2 does not exist")
|
||||
// fail()
|
||||
}
|
||||
|
||||
shell.Run("mount /dev/mmcblk0p2 /home/factory")
|
||||
|
||||
imagename := "factory-2019-01-20"
|
||||
fullname := "/home/factory/" + imagename
|
||||
|
||||
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")
|
||||
} 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=16M status=progress
|
||||
|
||||
echo sync
|
||||
sync
|
||||
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
|
||||
|
||||
echo
|
||||
echo
|
||||
echo INSTALL SUCCEEDED
|
||||
echo INSTALL SUCCEEDED
|
||||
echo INSTALL SUCCEEDED
|
||||
echo INSTALL SUCCEEDED
|
||||
echo
|
||||
echo
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
func fail () {
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("INSTALL FAILED")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
func succeeded () {
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("INSTALL SUCCEEDED")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
log.Println("")
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue