From 8f7a25d9c879ae740ba8e2c4fe141d2e2359db86 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 9 Apr 2019 14:36:09 -0700 Subject: [PATCH] add dd and ping git.wit.com Signed-off-by: Jeff Carr --- connect-to-wifi/main.go | 2 +- make-sdcard/main.go | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/connect-to-wifi/main.go b/connect-to-wifi/main.go index 0b27dac..8d84a45 100644 --- a/connect-to-wifi/main.go +++ b/connect-to-wifi/main.go @@ -34,7 +34,7 @@ func main() { for { time.Sleep(1000 * time.Millisecond) - ping := shell.Run("ping -c 1 localhost") + ping := shell.Run("ping -c 1 git.wit.com") log.Println("ping returned ", ping) if (ping == 0) { break diff --git a/make-sdcard/main.go b/make-sdcard/main.go index 1a2d79f..032f0d5 100644 --- a/make-sdcard/main.go +++ b/make-sdcard/main.go @@ -8,6 +8,8 @@ import "github.com/gookit/config" import "github.com/andlabs/ui" import "github.com/davecgh/go-spew/spew" +import "git.wit.com/jcarr/shell" + var mainwin *ui.Window var mydrive string @@ -27,6 +29,33 @@ func rsync(mybut *ui.Button) { } } +func dd(mybut *ui.Button) int { + if _, err := os.Stat("/mnt/factory-image/lost+found/"); os.IsNotExist(err) { + shell.Run("mkdir /mnt/factory-image/") + shell.Run("mount /dev/sdb2 /mnt/factory-image/") + } + if _, err := os.Stat("/mnt/factory-image/lost+found/"); os.IsNotExist(err) { + log.Println("partition is not mounted") + ui.MsgBoxError(mainwin, "The partition is not mounted at /mnt/sdcard", "") + return -1 + } + + + script("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); + + log.Println("run rsync here") + script(` + rsync -av --progress --inplace /home/pinebook/factory/FACTORY-IMAGER-ROOTFS/ /mnt/sdcard/ + umount /mnt/sdcard + `) + ui.MsgBox(mainwin, "The sdcard is finished", "") + } else { + log.Println("partition is not mounted") + ui.MsgBoxError(mainwin, "The partition is not mounted at /mnt/sdcard", "") + } + return 0 +} + // select the dev entry to partition and format // for example: /dev/mtdblock0 or /dev/sdc func selectDrive(mybox *ui.Combobox) { @@ -105,6 +134,7 @@ func makeBurnSDcardPage() *ui.Box { addButton(vbox2, "Partition and Format", format) addButton(vbox2, "rsync filesystem", rsync) + addButton(vbox2, "dd image", dd) return hbox } @@ -133,7 +163,5 @@ func setupUI() { func main() { parseConfig() - // script("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); - ui.Main(setupUI) }