diff options
| author | Jeff Carr <[email protected]> | 2023-12-16 09:36:40 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-16 09:36:40 -0600 |
| commit | e9f1723dbc8dab3bd84f7006723f6ae9c97df88c (patch) | |
| tree | 347243f04017721251f61292646c75cf307b2d1a /hostname.go | |
| parent | 27696b976485f989d664f330e9c328de93e8e672 (diff) | |
hostname check basically working
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'hostname.go')
| -rw-r--r-- | hostname.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/hostname.go b/hostname.go index cf033df..62803c1 100644 --- a/hostname.go +++ b/hostname.go @@ -42,9 +42,19 @@ func getHostname() { // On Linux, /etc/hosts, /etc/hostname // and domainname and hostname func goodHostname(h string) bool { - hostname := shell.Cat("/etc/hostname") + hostname := shell.Chomp(shell.Cat("/etc/hostname")) log.Println("hostname =", hostname) + hs := run("hostname -s") + dn := run("domainname") + log.Println("hostname short =", hs, "domainname =", dn) + + tmp := hs + "." + dn + if (hostname == tmp) { + log.Println("hostname seems to be good", hostname) + return true + } + return false } |
