diff --git a/Makefile b/Makefile index 559910d..c3a323f 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,14 @@ build: go build -v ./wit-new-machine --debugging +goimports: + goimports -w *.go + +redomod: + rm -f go.* + go mod init + go mod tidy + nocui: ./wit-new-machine --gui-toolkit nocui diff --git a/apt.go b/apt.go index 8f6bbaf..45c3442 100644 --- a/apt.go +++ b/apt.go @@ -1,4 +1,5 @@ package main + import ( "log" "os" @@ -8,7 +9,7 @@ func aptTab() { aptTab := mainWindow.NewTab("apt") box := aptTab.NewBox("aptBox", false) - box.NewButton("apt sources", func () { + box.NewButton("apt sources", func() { if _, err := os.Stat("/etc/apt/sources.list.d/wit.list"); err == nil { log.Println("apt sources are already configured") } else { @@ -25,7 +26,7 @@ func aptTab() { } }) - box.NewButton("apt-file", func () { + box.NewButton("apt-file", func() { myGui.CloseToolkit("gocui") doCmd("apt install apt-file") doCmd("apt-file update") @@ -34,7 +35,7 @@ func aptTab() { os.Exit(0) }) - box.NewButton("install defaults", func () { + box.NewButton("install defaults", func() { myGui.CloseToolkit("gocui") doCmd("apt install lsof bash-completion libpam-systemd dbus rbd-nbd golang-go git screen vim " + "ethstatus iftop ethtool sysstat traceroute whois devscripts automake libtool devscripts " + diff --git a/args.go b/args.go index d5d3124..4010b45 100644 --- a/args.go +++ b/args.go @@ -4,10 +4,10 @@ package main this enables command line options from other packages like 'gui' and 'log' */ -import ( +import ( + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/debugger" "go.wit.com/log" - "go.wit.com/arg" - "go.wit.com/gui/debugger" ) var argGui ArgsGui diff --git a/go.mod b/go.mod index 8cc638e..0569958 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,23 @@ module git.wit.org/jcarr/wit-new-machine go 1.21.4 require ( - github.com/alexflint/go-arg v1.4.3 - go.wit.com/gui/gui v0.9.8 - go.wit.com/log v0.0.0-20240102010317-907893ba7b4b - golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a + go.wit.com/arg v1.4.4 + go.wit.com/dev/alexflint/arg v1.4.5 + go.wit.com/gui v0.13.11 + go.wit.com/lib/debugger v0.12.7 + go.wit.com/log v0.5.6 + golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b ) require ( - github.com/alexflint/go-scalar v1.1.0 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.9.0 // indirect - go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 // indirect + github.com/alexflint/go-scalar v1.2.0 // indirect + go.wit.com/dev/alexflint/scalar v1.2.1 // indirect + go.wit.com/dev/davecgh/spew v1.1.4 // indirect + go.wit.com/lib/gadgets v0.12.14 // indirect + go.wit.com/lib/gui/logsettings v0.10.2 // indirect + go.wit.com/widget v1.1.6 // indirect golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect - golang.org/x/image v0.14.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/image v0.15.0 // indirect + golang.org/x/sys v0.16.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 569c5f6..d3ada4e 100644 --- a/go.sum +++ b/go.sum @@ -1,39 +1,40 @@ -github.com/alexflint/go-arg v1.4.3 h1:9rwwEBpMXfKQKceuZfYcwuc/7YY7tWJbFsgG5cAU/uo= -github.com/alexflint/go-arg v1.4.3/go.mod h1:3PZ/wp/8HuqRZMUUgu7I+e1qcpUbvmS258mRXkFH4IA= -github.com/alexflint/go-scalar v1.1.0 h1:aaAouLLzI9TChcPXotr6gUhq+Scr8rl0P9P4PnltbhM= -github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw= +github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= -github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -go.wit.com/gui/gui v0.9.8 h1:oMqM4sfucMnZxh9e2F0DKxNTuVxl2JZGXcuTRnGW+xI= -go.wit.com/gui/gui v0.9.8/go.mod h1:H2+uDT6qoQ8UkV6QUNIC1MQsgy6/aAop0zWBHnwACso= -go.wit.com/log v0.0.0-20240102010317-907893ba7b4b h1:YqDB6AChqjmt5jYN4F79UrjIDoUt58pfCgXJwp+G2wg= -go.wit.com/log v0.0.0-20240102010317-907893ba7b4b/go.mod h1:GmsggfsKrqdZdAj26fEOlcTz6qEIazbV33uyuuktvB8= -go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4= -go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +go.wit.com/arg v1.4.4 h1:nfW8JUsVfyXi5l3BlTq5GGhesLlnyh3ICIm8cpM2U8w= +go.wit.com/arg v1.4.4/go.mod h1:P2JoYIsJ9SSvp45qSnYibQEQPNTuTB8dTkyT9y1btsI= +go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY= +go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0= +go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs= +go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= +go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= +go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= +go.wit.com/gui v0.13.11 h1:d74Ko/XFZYR25P/AZfCQaVO2CuGh1BSjdUp1wjktdDg= +go.wit.com/gui v0.13.11/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA= +go.wit.com/lib/debugger v0.12.7 h1:c8ehU7p2asb//K4YgC17XG4o2pPP+IZb9lR2a0nBio8= +go.wit.com/lib/debugger v0.12.7/go.mod h1:zcZstsgOcALjCNOiIE+KcKkrIF78ogYjwxmaQlBbmtQ= +go.wit.com/lib/gadgets v0.12.14 h1:Osh7D8TKJiU5M6tXqERGQwTUt+C5IJ0senkmUAirSek= +go.wit.com/lib/gadgets v0.12.14/go.mod h1:Fxc7F8hGskpkWVAsXKhs4ilqUlAnikVXj4yzumtTYa0= +go.wit.com/lib/gui/logsettings v0.10.2 h1:xRx0AX1V74kC6CIm+ib6C3ziTcbBjR/Ju3rTLEpQMsw= +go.wit.com/lib/gui/logsettings v0.10.2/go.mod h1:v5XUQ6WyNyfScR9oOFhdz8p1wtxCpNWXK3DJ/dbLPVo= +go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= +go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= +go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY= +go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 h1:3AGKexOYqL+ztdWdkB1bDwXgPBuTS/S8A4WzuTvJ8Cg= golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0= -golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= -golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= -golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a h1:sYbmY3FwUWCBTodZL1S3JUuOvaW6kM2o+clDzzDNBWg= -golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a/go.mod h1:Ede7gF0KGoHlj822RtphAHK1jLdrcuRBZg0sF1Q+SPc= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= +golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b h1:kfWLZgb8iUBHdE9WydD5V5dHIS/F6HjlBZNyJfn2bs4= +golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b/go.mod h1:4efzQnuA1nICq6h4kmZRMGzbPiP06lZvgADUu1VpJCE= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/gui.go b/gui.go index d20fba3..f6c4c71 100644 --- a/gui.go +++ b/gui.go @@ -1,11 +1,13 @@ package main + import ( - "time" - "os" "io/ioutil" + "os" + "time" + + "go.wit.com/lib/debugger" + "go.wit.com/gui" "go.wit.com/log" - "go.wit.com/gui/gui" - "go.wit.com/gui/debugger" ) var myGui *gui.Node @@ -29,10 +31,10 @@ var resolv *gui.Node func writeRes(indir string, outdir string, name string) { tmp, _ := res.ReadFile(indir + name) - ioutil.WriteFile(outdir + name, tmp, 0644) + ioutil.WriteFile(outdir+name, tmp, 0644) } -// myGui = gui.New().LoadToolkit("gocui") +// myGui = gui.New().LoadToolkit("gocui") func drawWindow() { var g *gui.Node @@ -57,14 +59,14 @@ func drawWindow() { ///////////////////////////////////////////////////////////////////////////// rn := newTab.NewGroup("Local Linux Settings") - rn.NewButton("purge rc-only", func () { + rn.NewButton("purge rc-only", func() { xterm("cd ~/jcarr/setup; make reset-purge-rc-only-packages") }) - rn.NewButton("install kvm", func () { + rn.NewButton("install kvm", func() { xterm("cd ~/jcarr/setup; make setup-packages-kvm") }) - rn.NewButton("ttyS0", func () { + rn.NewButton("ttyS0", func() { myGui.CloseToolkit("gocui") // systemctl enable serial-getty@ttyS0.service // cp ttyS0.conf /etc/init/ @@ -89,19 +91,19 @@ func drawWindow() { } os.Exit(0) }) - rn.NewButton("git config", func () { + rn.NewButton("git config", func() { myGui.CloseToolkit("gocui") doCmd("git config pull.rebase false") os.Exit(0) }) - rn.NewButton("DebugWindow()", func () { + rn.NewButton("DebugWindow()", func() { debugger.DebugWindow(myGui) }) rn.NewLabel("Not yet working stuff") - rn.NewButton("resolv.conf", func () { + rn.NewButton("resolv.conf", func() { s := resolv.GetText() log.Println("supposed to make the resolv.conf window\n\n", s) }) diff --git a/main.go b/main.go index bdfdae6..b6c5cdf 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,16 @@ package main import ( + "bytes" + "embed" "os" "os/exec" - "embed" "strings" - "bytes" "go.wit.com/arg" + "go.wit.com/lib/debugger" + "go.wit.com/gui" "go.wit.com/log" - "go.wit.com/gui/gui" - "go.wit.com/gui/debugger" ) var GITCOMMIT string // this is passed in as an ldflag @@ -22,7 +22,6 @@ var username string var hostname string var geom string = "120x30+500+500" - //go:embed resources var res embed.FS @@ -64,6 +63,6 @@ func main() { } func closeWindow(n *gui.Node) { - log.Println("Just closing the window and nothing else.", n.Name) + log.Println("Just closing the window and nothing else.", n.Name) // os.Exit(0) } diff --git a/os.go b/os.go index 3fe7474..df12a05 100644 --- a/os.go +++ b/os.go @@ -1,16 +1,18 @@ package main -import "log" -import "strings" -import "os" -import "os/exec" -import "io/ioutil" -import "errors" +import ( + "errors" + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) func runSimpleCommand(s string) { - cmd := strings.TrimSpace(s) // this is like 'chomp' in perl - cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl - cmdArgs := strings.Fields(cmd) + cmd := strings.TrimSpace(s) // this is like 'chomp' in perl + cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl + cmdArgs := strings.Fields(cmd) runLinuxCommand(cmdArgs) } diff --git a/setup.go b/setup.go index 89c343a..949f071 100644 --- a/setup.go +++ b/setup.go @@ -1,7 +1,7 @@ package main import ( - "go.wit.com/gui/gui" + "go.wit.com/gui" ) // setup a new machine @@ -15,43 +15,43 @@ func setupNewMachine(cur *gui.Node) { w = cur.NewTab("Setup Machine") g = w.NewGroup("ssh things") - g.NewButton("ssh localhost", func () { + g.NewButton("ssh localhost", func() { // ssh -t == force pseudo tty allocation command = "ssh -t " + username + "@" + hostname + " 'ssh -v localhost'" commandEntry.SetText(command) }) - g.NewButton("copy authorized_keys", func () { + g.NewButton("copy authorized_keys", func() { command = "scp ~/jcarr/.ssh/authorized_keys " + username + "@[" + hostname + "]:.ssh" + "/" commandEntry.SetText(command) }) - g.NewButton("sudo ssh localhost", func () { + g.NewButton("sudo ssh localhost", func() { // ssh -t == force pseudo tty allocation command = "ssh -t " + username + "@" + hostname + " 'sudo ssh -v localhost'" commandEntry.SetText(command) }) - g.NewButton("sudo cp authorized_keys", func () { + g.NewButton("sudo cp authorized_keys", func() { command = "ssh -t " + username + "@" + hostname + " 'sudo cp /home/jcarr/.ssh/authorized_keys /root/.ssh/ ' " commandEntry.SetText(command) }) g.NewLabel("install go 1.19") - g.NewButton("wget 1.19", func () { + g.NewButton("wget 1.19", func() { command = "ssh -t " + "jcarr" + "@" + hostname + " 'wget https://go.dev/dl/go1.19.linux-amd64.tar.gz' " xtermHold.Set(true) xterm(command) }) g.NewLabel("install sid") - g.NewButton("replace /etc/apt/sources", func () { + g.NewButton("replace /etc/apt/sources", func() { commandEntry.SetText(command) }) - g.NewButton("apt update", func () { + g.NewButton("apt update", func() { // command = "ssh -t " + 'root' + "@" + hostname + " 'cp /home/jcarr/.ssh/authorized_keys /root/.ssh/ ' " commandEntry.SetText(command) }) g.NewLabel("build myself") - g.NewButton("setup go", func () { + g.NewButton("setup go", func() { // ssh -t == force pseudo tty allocation command = "ssh -t " + "jcarr" + "@" + hostname + " 'go get -u -v go.wit.com/jcarr/control-panel-dns ; bash'" commandEntry.SetText(command)