summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hostname-controller.lua2
-rw-r--r--hostname-model.lua19
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)