parent
40e811b3b3
commit
7e1460f9f6
5
Makefile
5
Makefile
|
@ -1,8 +1,5 @@
|
|||
all:
|
||||
@echo
|
||||
@echo Run: make redomod
|
||||
@echo
|
||||
@# ./myrepos >/tmp/myrepos.stderr 2>&1
|
||||
GO111MODULE=off go vet
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
|
35
hostname.go
35
hostname.go
|
@ -3,8 +3,11 @@
|
|||
package linuxstatus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
|
||||
// will try to get this hosts FQDN
|
||||
|
@ -80,6 +83,17 @@ func (ls *LinuxStatus) setHostShort() {
|
|||
}
|
||||
}
|
||||
|
||||
// getDomainName extracts the domain name from a given hostname
|
||||
func getDomainName(hostname string) (string, error) {
|
||||
parts := strings.Split(hostname, ".")
|
||||
if len(parts) < 3 {
|
||||
return "", fmt.Errorf("hostname '%s' is too short to extract a domain name", hostname)
|
||||
}
|
||||
// Join all parts except the first one, which is assumed to be a subdomain
|
||||
domain := strings.Join(parts[1:], ".")
|
||||
return domain, nil
|
||||
}
|
||||
|
||||
func lookupHostname() {
|
||||
if !me.Ready() {
|
||||
return
|
||||
|
@ -107,6 +121,27 @@ func lookupHostname() {
|
|||
if hostfqdn != hostname {
|
||||
log.Log(WARN, "hostname", hostname, "does not equal fqdn.FqdnHostname()", hostfqdn)
|
||||
// TODO: figure out what is wrong
|
||||
if dn == "(none)" {
|
||||
realdn, err := getDomainName(hostfqdn)
|
||||
if err == nil {
|
||||
log.Log(WARN, "need to run: 'domainname", realdn, "' here")
|
||||
me.changed = true
|
||||
me.hostnameStatus.SetText("FIXING")
|
||||
shell.RunPath("", []string{"domainname", realdn})
|
||||
return
|
||||
} else {
|
||||
log.Log(WARN, "getDomainName() err =", err)
|
||||
log.Log(WARN, "/etc/hostname is too short. let the user set the name here.")
|
||||
// me.changed = true
|
||||
me.hostnameStatus.SetText("INVALID DOMAIN NAME")
|
||||
// return
|
||||
}
|
||||
}
|
||||
log.Log(WARN, "don't know what to do here with domainname")
|
||||
log.Log(WARN, "check that /etc/hostname is valid?")
|
||||
// me.changed = true
|
||||
me.hostnameStatus.SetText("UNKNOWN")
|
||||
// return
|
||||
}
|
||||
|
||||
var test string
|
||||
|
|
|
@ -44,7 +44,7 @@ func linuxLoop() {
|
|||
sort.Strings(a)
|
||||
tmp := strings.Join(a, "\n")
|
||||
if tmp != me.workingIPv4.String() {
|
||||
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
||||
log.Log(CHANGE, "realA() your real IPv6 addresses changed")
|
||||
me.changed = true
|
||||
me.workingIPv4.SetText(tmp)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue