From 063b4bc98bb71433ee59dafa782e3f241bd814c1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 22 Apr 2023 12:51:13 -0500 Subject: [PATCH] setup ttyS0 might work Signed-off-by: Jeff Carr --- args.go | 1 + main.go | 27 +++++++++++++++++++++ resources/sources.list.d/bazel.list | 5 ++++ resources/sources.list.d/debian.list | 26 ++++++++++++++++++++ resources/sources.list.d/gcloud.list | 1 + resources/sources.list.d/google-chrome.list | 3 +++ resources/sources.list.d/picoscope.list | 1 + resources/sources.list.d/signal.list | 3 +++ resources/sources.list.d/wit.list | 2 ++ resources/ttyS0.conf | 10 ++++++++ window-main.go | 17 ++++++++++--- 11 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 resources/sources.list.d/bazel.list create mode 100644 resources/sources.list.d/debian.list create mode 100644 resources/sources.list.d/gcloud.list create mode 100644 resources/sources.list.d/google-chrome.list create mode 100644 resources/sources.list.d/picoscope.list create mode 100644 resources/sources.list.d/signal.list create mode 100644 resources/sources.list.d/wit.list create mode 100644 resources/ttyS0.conf diff --git a/args.go b/args.go index c7249c8..eeff727 100644 --- a/args.go +++ b/args.go @@ -10,6 +10,7 @@ var args struct { LogFile string Verbose bool User string `arg:"env:USER"` + TestExec string gui.GuiArgs } diff --git a/main.go b/main.go index 5dc14ba..4eff94c 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,12 @@ package main import ( + "os" + "os/exec" "log" "embed" + "strings" + "bytes" "git.wit.org/wit/gui" ) @@ -19,9 +23,32 @@ var geom string = "120x30+500+500" //go:embed resources var res embed.FS +//go:embed resources/ttyS0.conf +var ttyS0 string + +func doCmd(str string) { + var stderr bytes.Buffer + log.Println("TestExec =", args.TestExec) + args := strings.Split(str, " ") + cmd := exec.Command(args[0], args[1:]...) + cmd.Stdout = os.Stdout + cmd.Stderr = &stderr // os.Stderr + err := cmd.Run() + if err != nil { + log.Println("Error:", err) + } + log.Println("STDERR:\n", stderr.String()) +} + func main() { log.Println("starting my Control Panel") + if (args.TestExec != "") { + // for i, t := range args.Toolkit { + doCmd(args.TestExec) + os.Exit(0) + } + initGUI() gui.Watchdog() } diff --git a/resources/sources.list.d/bazel.list b/resources/sources.list.d/bazel.list new file mode 100644 index 0000000..3a50eba --- /dev/null +++ b/resources/sources.list.d/bazel.list @@ -0,0 +1,5 @@ +# sudo apt install -y apt-transport-https curl gnupg +# curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg +# sudo mv bazel-archive-keyring.gpg /usr/share/keyrings + +# deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8 diff --git a/resources/sources.list.d/debian.list b/resources/sources.list.d/debian.list new file mode 100644 index 0000000..e0ad7ce --- /dev/null +++ b/resources/sources.list.d/debian.list @@ -0,0 +1,26 @@ +# See https://wiki.debian.org/SourcesList for more information. + +deb http://mirrors.lab.wit.org/debian sid main contrib non-free non-free-firmware +deb-src http://mirrors.lab.wit.org/debian sid main contrib non-free non-free-firmware + +# deb http://mirrors.cogentco.com/debian sid main contrib non-free + +# deb http://mirrors.kernel.org/debian sid main contrib non-free + +# deb-src http://deb.debian.org/debian bullseye main + +# deb http://deb.debian.org/debian bullseye-updates main +# deb-src http://deb.debian.org/debian bullseye-updates main + +# deb http://security.debian.org/debian-security/ bullseye-security main +# deb-src http://security.debian.org/debian-security/ bullseye-security main +# See https://wiki.debian.org/SourcesList for more information. + +#deb http://deb.debian.org/debian bullseye main +#deb-src http://deb.debian.org/debian bullseye main + +#deb http://deb.debian.org/debian bullseye-updates main +#deb-src http://deb.debian.org/debian bullseye-updates main + +#deb http://security.debian.org/debian-security/ bullseye-security main +#deb-src http://security.debian.org/debian-security/ bullseye-security main diff --git a/resources/sources.list.d/gcloud.list b/resources/sources.list.d/gcloud.list new file mode 100644 index 0000000..2242481 --- /dev/null +++ b/resources/sources.list.d/gcloud.list @@ -0,0 +1 @@ +# deb [signed-by=/etc/wit/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main diff --git a/resources/sources.list.d/google-chrome.list b/resources/sources.list.d/google-chrome.list new file mode 100644 index 0000000..97cf573 --- /dev/null +++ b/resources/sources.list.d/google-chrome.list @@ -0,0 +1,3 @@ +### THIS FILE IS AUTOMATICALLY CONFIGURED ### +# You may comment out this entry, but any other modifications may be lost. +# deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main diff --git a/resources/sources.list.d/picoscope.list b/resources/sources.list.d/picoscope.list new file mode 100644 index 0000000..fdb99fc --- /dev/null +++ b/resources/sources.list.d/picoscope.list @@ -0,0 +1 @@ +# deb https://labs.picotech.com/picoscope7auto/debian/ picoscope main diff --git a/resources/sources.list.d/signal.list b/resources/sources.list.d/signal.list new file mode 100644 index 0000000..6f6e3ba --- /dev/null +++ b/resources/sources.list.d/signal.list @@ -0,0 +1,3 @@ +# deb [arch=amd64 signed-by=/etc/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main +# deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/signal-keys.asc] https://updates.signal.org/desktop/apt xenial main +# deb-src [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/signal-keys.asc] https://updates.signal.org/desktop/apt xenial main diff --git a/resources/sources.list.d/wit.list b/resources/sources.list.d/wit.list new file mode 100644 index 0000000..a3b9ea2 --- /dev/null +++ b/resources/sources.list.d/wit.list @@ -0,0 +1,2 @@ +deb [signed-by=/etc/wit/wit.gpg] http://mirrors.wit.org/wit/ sid main +deb-src [signed-by=/etc/wit/wit.gpg] http://mirrors.wit.org/wit/ sid main diff --git a/resources/ttyS0.conf b/resources/ttyS0.conf new file mode 100644 index 0000000..0ed8550 --- /dev/null +++ b/resources/ttyS0.conf @@ -0,0 +1,10 @@ +# ttyS0 - getty +# +# This service maintains a getty on ttyS0 from the point the system is +# started until it is shut down again. + +start on stopped rc RUNLEVEL=[12345] +stop on runlevel [!12345] + +respawn +exec /sbin/getty -L 115200 ttyS0 vt102 diff --git a/window-main.go b/window-main.go index cad1380..440f7d6 100644 --- a/window-main.go +++ b/window-main.go @@ -3,6 +3,7 @@ import ( "log" "time" "os" + "io/ioutil" "git.wit.org/wit/gui" ) @@ -10,7 +11,7 @@ var myGui *gui.Node var mainWindow *gui.Node func initGUI() { - myGui = gui.New() + myGui = gui.New().LoadToolkit("gocui") mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup") mainWindow.Custom = customExit @@ -54,8 +55,6 @@ func mainTab(n *gui.Node) { ///////////////////////////////////////////////////////////////////////////// rn := newTab.NewGroup("Local Linux Settings") - rn.NewLabel("need to be run as root") - rn.NewButton("apt sources", func () { xterm("cd ~/jcarr/setup; make setup-apt-sources; make setup-apt-file") }) @@ -69,6 +68,18 @@ func mainTab(n *gui.Node) { xterm("cd ~/jcarr/setup; make setup-packages-kvm") }) + rn.NewButton("ttyS0", func () { + // systemctl enable serial-getty@ttyS0.service + // cp ttyS0.conf /etc/init/ + foo := []byte(ttyS0) + ioutil.WriteFile("/etc/init/ttyS0.conf", foo, 0644) + myGui.CloseToolkit("gocui") + doCmd("ls -l") + doCmd("cat /etc/init/ttyS0.conf") + doCmd("systemctl enable serial-getty@ttyS0.service") + os.Exit(0) + }) + rn.NewLabel("Not yet working stuff") rn.NewButton("resolv.conf", func () {