summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-15 12:15:10 -0600
committerJeff Carr <[email protected]>2025-02-15 12:21:36 -0600
commitb7b18626d87dd42d5e5fe4fac8ff66eeb9836ee9 (patch)
treebfc32effd3e69f97b3c7b2ca52131cd930bdc287 /init.go
parent7900b1416e94feeadf133232e33f2938b672702f (diff)
more on Machine.Init()
Diffstat (limited to 'init.go')
-rw-r--r--init.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/init.go b/init.go
index 94c3cf0..2da1427 100644
--- a/init.go
+++ b/init.go
@@ -6,6 +6,7 @@ import (
"os"
"os/user"
"path/filepath"
+ "strings"
"time"
"go.wit.com/lib/gui/shell"
@@ -133,6 +134,27 @@ func (f *Forge) InitPB() {
}
}
+func (f *Forge) InitMachine() {
+ f.Machine = new(zoopb.Machine)
+ if err := f.Machine.ConfigLoad(); err != nil {
+ log.Log(WARN, "zoopb.ConfigLoad() failed", err)
+ f.Machine.InitWit()
+ }
+
+ if f.Config.Username == "" {
+ usr, _ := user.Current()
+ f.Config.Username = usr.Username
+ }
+
+ if f.Machine.Hostname == "" {
+ r, err := shell.RunVerbose([]string{"hostname", "-f"})
+ if err == nil {
+ tmp := strings.Join(r.Stdout, "\n")
+ f.Machine.Hostname = strings.TrimSpace(tmp)
+ }
+ }
+}
+
// only init's the protobuf. intended to not scan or change anything
func InitPB() *Forge {
f := DetermineGoPath()