diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-01-20 13:34:15 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-01-20 13:34:15 +0000 |
commit | b2f01eefe16bc19797360ee2a05805e6dc330d38 (patch) | |
tree | fd3759e41271c7cdabbeff6316a769d7eb12306e | |
parent | 301c747b1f0532d81e4a919a09ad80026460c96b (diff) | |
download | acf-alpine-baselayout-b2f01eefe16bc19797360ee2a05805e6dc330d38.tar.bz2 acf-alpine-baselayout-b2f01eefe16bc19797360ee2a05805e6dc330d38.tar.xz |
Change hostname get to return fqdn if available.
-rw-r--r-- | hostname-controller.lua | 2 | ||||
-rw-r--r-- | hostname-model.lua | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/hostname-controller.lua b/hostname-controller.lua index 10ab81c..623373f 100644 --- a/hostname-controller.lua +++ b/hostname-controller.lua @@ -6,7 +6,7 @@ require("controllerfunctions") default_action = "read" read = function(self) - return self.model.get() + return self.model.get(true) end edit = function(self) diff --git a/hostname-model.lua b/hostname-model.lua index 7d4238e..c11102c 100644 --- a/hostname-model.lua +++ b/hostname-model.lua @@ -3,16 +3,25 @@ module (..., package.seeall) require("fs") -get = function (self) - local f = io.popen("/bin/hostname") - local n = f:read("*a") or "unknown" - f:close() +get = function (fqdn) + local f,n + if fqdn then + f = io.popen("/bin/hostname -f") + n = f:read("*a") + f:close() + end + if not n or n == "" then + f = io.popen("/bin/hostname") + n = f:read("*a") or "unknown" + f:close() + end + return cfe({value=n, label="Hostname"}) end read_name = function () - return cfe({ type="group", value={hostname=get()}, label="Hostname" }) + return cfe({ type="group", value={hostname=get(false)}, label="Hostname" }) end update_name = function(name) |