Compare commits

..

No commits in common. "guimaster" and "master" have entirely different histories.

11 changed files with 143 additions and 86 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
*.swp
go.*
wit-new-machine
/files/*
/*.deb

View File

@ -6,18 +6,9 @@ VERSION = $(shell cat resources/VERSION)
# export GO111MODULE="off"
build:
-mkdir plugins
-cp ~/go/src/go.wit.com/toolkits/*.so plugins/
-cp ~/go/src/go.wit.com/gui/toolkits/*.so plugins/
go build -v
./wit-new-machine
goimports:
goimports -w *.go
redomod:
rm -f go.*
GO111MODULE= go mod init
GO111MODULE= go mod tidy
./wit-new-machine --debugging
nocui:
./wit-new-machine --gui-toolkit nocui

11
apt.go
View File

@ -1,17 +1,14 @@
package main
import (
"log"
"os"
"go.wit.com/gui"
)
func aptTab() {
aptTab := gui.RawWindow("apt")
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 {
@ -28,7 +25,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")
@ -37,7 +34,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 " +

28
args.go Normal file
View File

@ -0,0 +1,28 @@
package main
/*
this enables command line options from other packages like 'gui' and 'log'
*/
import (
"go.wit.com/log"
"go.wit.com/arg"
"go.wit.com/gui/debugger"
)
var argGui ArgsGui
// This struct can be used with the go-arg package
type ArgsGui struct {
Test bool `arg:"--test" help:"enable all logging"`
}
func init() {
arg.MustParse(&argGui)
if debugger.ArgDebug() {
log.Log(true, "INIT() gui debug == true")
} else {
log.Log(true, "INIT() gui debug == false")
}
}

View File

@ -1,26 +0,0 @@
package main
/*
enables GUI options and the debugger in your application
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
var args struct {
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

21
go.mod Normal file
View File

@ -0,0 +1,21 @@
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
)
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
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
)

39
go.sum Normal file
View File

@ -0,0 +1,39 @@
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/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=
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=
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=

31
gui.go
View File

@ -1,12 +1,11 @@
package main
import (
"io/ioutil"
"os"
"time"
"go.wit.com/gui"
"os"
"io/ioutil"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/debugger"
)
var myGui *gui.Node
@ -30,17 +29,17 @@ 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
mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup")
mainWindow.Custom = customExit
newTab := gui.NewWindow("mainTab")
newTab := mainWindow.NewTab("mainTab")
//////////////////// General GUI debugging /////////////////////////
g = newTab.NewGroup("Debug")
@ -58,14 +57,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/
@ -90,16 +89,20 @@ 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 () {
debugger.DebugWindow(myGui)
})
rn.NewLabel("Not yet working stuff")
rn.NewButton("resolv.conf", func() {
s := resolv.String()
rn.NewButton("resolv.conf", func () {
s := resolv.GetText()
log.Println("supposed to make the resolv.conf window\n\n", s)
})

17
main.go
View File

@ -1,15 +1,16 @@
package main
import (
"bytes"
"embed"
"os"
"os/exec"
"embed"
"strings"
"bytes"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
"go.wit.com/arg"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/debugger"
)
var GITCOMMIT string // this is passed in as an ldflag
@ -21,6 +22,7 @@ var username string
var hostname string
var geom string = "120x30+500+500"
//go:embed resources
var res embed.FS
@ -53,10 +55,15 @@ func main() {
myGui = gui.New().Default()
drawWindow()
if debugger.ArgDebug() {
log.Sleep(2)
debugger.DebugWindow(myGui)
}
gui.Watchdog()
}
func closeWindow(n *gui.Node) {
log.Println("Just closing the window and nothing else.", n.String())
log.Println("Just closing the window and nothing else.", n.Name)
// os.Exit(0)
}

20
os.go
View File

@ -1,18 +1,16 @@
package main
import (
"errors"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
)
import "log"
import "strings"
import "os"
import "os/exec"
import "io/ioutil"
import "errors"
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)
}

View File

@ -1,7 +1,7 @@
package main
import (
"go.wit.com/gui"
"go.wit.com/gui/gui"
)
// setup a new machine
@ -12,46 +12,46 @@ var commandEntry *gui.Node
func setupNewMachine(cur *gui.Node) {
var w, g *gui.Node
w = myGui.NewWindow("Setup Machine")
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.SetChecked(true)
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)