2023-04-12 12:21:23 -05:00
|
|
|
package main
|
2024-01-24 22:02:08 -06:00
|
|
|
|
2023-04-12 12:21:23 -05:00
|
|
|
import (
|
2023-04-22 12:51:13 -05:00
|
|
|
"io/ioutil"
|
2024-01-24 22:02:08 -06:00
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.wit.com/gui"
|
2024-01-03 22:09:15 -06:00
|
|
|
"go.wit.com/log"
|
2023-04-12 12:21:23 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-04-22 15:19:28 -05:00
|
|
|
func writeRes(indir string, outdir string, name string) {
|
|
|
|
tmp, _ := res.ReadFile(indir + name)
|
2024-01-24 22:02:08 -06:00
|
|
|
ioutil.WriteFile(outdir+name, tmp, 0644)
|
2023-04-22 15:19:28 -05:00
|
|
|
}
|
|
|
|
|
2024-01-24 22:02:08 -06:00
|
|
|
// myGui = gui.New().LoadToolkit("gocui")
|
2023-04-23 11:30:39 -05:00
|
|
|
func drawWindow() {
|
2023-04-12 12:21:23 -05:00
|
|
|
var g *gui.Node
|
|
|
|
|
2023-04-23 11:30:39 -05:00
|
|
|
mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup")
|
|
|
|
mainWindow.Custom = customExit
|
|
|
|
|
2024-02-15 03:28:16 -06:00
|
|
|
newTab := gui.NewWindow("mainTab")
|
2023-04-12 12:21:23 -05:00
|
|
|
|
|
|
|
//////////////////// General GUI debugging /////////////////////////
|
|
|
|
g = newTab.NewGroup("Debug")
|
2023-04-23 14:41:23 -05:00
|
|
|
// g = mainWindow.NewGroup("Debug")
|
2023-04-12 12:21:23 -05:00
|
|
|
|
|
|
|
padding = g.NewCheckbox("padding")
|
|
|
|
xtermHold = g.NewCheckbox("xterm -hold")
|
|
|
|
firefox = g.NewCheckbox("Use Firefox")
|
|
|
|
|
|
|
|
g.NewLabel("resolv.conf")
|
|
|
|
resolv = g.NewTextbox("resolv")
|
2023-05-23 10:29:37 -05:00
|
|
|
resolv.Dump()
|
2023-04-12 12:21:23 -05:00
|
|
|
resolv.SetText("hello world\nfoo bar\n")
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
rn := newTab.NewGroup("Local Linux Settings")
|
|
|
|
|
2024-01-24 22:02:08 -06:00
|
|
|
rn.NewButton("purge rc-only", func() {
|
2023-04-12 12:21:23 -05:00
|
|
|
xterm("cd ~/jcarr/setup; make reset-purge-rc-only-packages")
|
|
|
|
})
|
2024-01-24 22:02:08 -06:00
|
|
|
rn.NewButton("install kvm", func() {
|
2023-04-12 12:21:23 -05:00
|
|
|
xterm("cd ~/jcarr/setup; make setup-packages-kvm")
|
|
|
|
})
|
|
|
|
|
2024-01-24 22:02:08 -06:00
|
|
|
rn.NewButton("ttyS0", func() {
|
2023-04-22 13:00:37 -05:00
|
|
|
myGui.CloseToolkit("gocui")
|
2023-04-22 12:51:13 -05:00
|
|
|
// systemctl enable serial-getty@ttyS0.service
|
|
|
|
// cp ttyS0.conf /etc/init/
|
2023-04-22 14:29:03 -05:00
|
|
|
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 {
|
2023-04-22 15:19:28 -05:00
|
|
|
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)
|
2023-04-22 14:29:03 -05:00
|
|
|
doCmd("update-grub")
|
|
|
|
}
|
2023-04-22 13:00:37 -05:00
|
|
|
os.Exit(0)
|
|
|
|
})
|
2024-01-24 22:02:08 -06:00
|
|
|
rn.NewButton("git config", func() {
|
2023-04-22 13:02:30 -05:00
|
|
|
myGui.CloseToolkit("gocui")
|
2023-04-22 13:00:37 -05:00
|
|
|
doCmd("git config pull.rebase false")
|
2023-04-22 12:51:13 -05:00
|
|
|
os.Exit(0)
|
|
|
|
})
|
|
|
|
|
2023-04-12 12:21:23 -05:00
|
|
|
rn.NewLabel("Not yet working stuff")
|
|
|
|
|
2024-01-24 22:02:08 -06:00
|
|
|
rn.NewButton("resolv.conf", func() {
|
2024-02-15 03:28:16 -06:00
|
|
|
s := resolv.String()
|
2023-04-12 12:21:23 -05:00
|
|
|
log.Println("supposed to make the resolv.conf window\n\n", s)
|
|
|
|
})
|
2023-04-23 14:41:23 -05:00
|
|
|
|
|
|
|
aptTab()
|
2023-04-12 12:21:23 -05:00
|
|
|
}
|