106 lines
2.7 KiB
Go
106 lines
2.7 KiB
Go
package main
|
|
import (
|
|
"log"
|
|
"time"
|
|
"os"
|
|
"io/ioutil"
|
|
"go.wit.com/gui"
|
|
)
|
|
|
|
var myGui *gui.Node
|
|
var mainWindow *gui.Node
|
|
|
|
func customExit() {
|
|
log.Println("Should Exit Here")
|
|
// window := gui.Data.WindowMap["Debugging2"]
|
|
// spew.Dump(window)
|
|
time.Sleep(2 * time.Second)
|
|
log.Println("")
|
|
log.Println("CLEAN EXIT")
|
|
log.Println("")
|
|
os.Exit(0)
|
|
}
|
|
|
|
var xtermHold *gui.Node
|
|
var padding *gui.Node
|
|
var firefox *gui.Node
|
|
var resolv *gui.Node
|
|
|
|
func writeRes(indir string, outdir string, name string) {
|
|
tmp, _ := res.ReadFile(indir + name)
|
|
ioutil.WriteFile(outdir + name, tmp, 0644)
|
|
}
|
|
|
|
// myGui = gui.New().LoadToolkit("gocui")
|
|
func drawWindow() {
|
|
var g *gui.Node
|
|
|
|
mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup")
|
|
mainWindow.Custom = customExit
|
|
|
|
newTab := mainWindow.NewTab("mainTab")
|
|
|
|
//////////////////// General GUI debugging /////////////////////////
|
|
g = newTab.NewGroup("Debug")
|
|
// g = mainWindow.NewGroup("Debug")
|
|
|
|
padding = g.NewCheckbox("padding")
|
|
xtermHold = g.NewCheckbox("xterm -hold")
|
|
firefox = g.NewCheckbox("Use Firefox")
|
|
|
|
g.NewLabel("resolv.conf")
|
|
resolv = g.NewTextbox("resolv")
|
|
resolv.Dump()
|
|
resolv.SetText("hello world\nfoo bar\n")
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
rn := newTab.NewGroup("Local Linux Settings")
|
|
|
|
rn.NewButton("purge rc-only", func () {
|
|
xterm("cd ~/jcarr/setup; make reset-purge-rc-only-packages")
|
|
})
|
|
rn.NewButton("install kvm", func () {
|
|
xterm("cd ~/jcarr/setup; make setup-packages-kvm")
|
|
})
|
|
|
|
rn.NewButton("ttyS0", func () {
|
|
myGui.CloseToolkit("gocui")
|
|
// systemctl enable serial-getty@ttyS0.service
|
|
// cp ttyS0.conf /etc/init/
|
|
if _, err := os.Stat("/etc/init.d/ttyS0"); err == nil {
|
|
log.Println("serial ttyS0 is already configured")
|
|
} else {
|
|
foo := []byte(ttyS0)
|
|
ioutil.WriteFile("/etc/init.d/ttyS0", foo, 0644)
|
|
doCmd("ls -l")
|
|
doCmd("cat /etc/init.d/ttyS0")
|
|
doCmd("systemctl enable serial-getty@ttyS0.service")
|
|
doCmd("service serial-getty@ttyS0 start")
|
|
// /etc/securetty
|
|
}
|
|
if _, err := os.Stat("/etc/default/grub.d/wit.cfg"); err == nil {
|
|
log.Println("Grub is already configured")
|
|
} else {
|
|
writeRes("resources/", "/etc/default/", "grub.d/wit.cfg")
|
|
// grub, _ := res.ReadFile("resources/grub.d/wit.cfg")
|
|
// ioutil.WriteFile("/etc/default/grub.d/wit.cfg", grub, 0644)
|
|
doCmd("update-grub")
|
|
}
|
|
os.Exit(0)
|
|
})
|
|
rn.NewButton("git config", func () {
|
|
myGui.CloseToolkit("gocui")
|
|
doCmd("git config pull.rebase false")
|
|
os.Exit(0)
|
|
})
|
|
|
|
rn.NewLabel("Not yet working stuff")
|
|
|
|
rn.NewButton("resolv.conf", func () {
|
|
s := resolv.GetText()
|
|
log.Println("supposed to make the resolv.conf window\n\n", s)
|
|
})
|
|
|
|
aptTab()
|
|
}
|