diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-10-13 20:51:39 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-10-13 20:51:39 +0000 |
commit | 4329b7b6da85440f537da8e4c1b9da1150912df3 (patch) | |
tree | 7733780e543cd6e738405f72114f94ffc8ecee6a /hostname-model.lua | |
parent | 303266d5fc5c1463a2aeecb2b4cc801b81ddfb06 (diff) | |
download | acf-alpine-baselayout-4329b7b6da85440f537da8e4c1b9da1150912df3.tar.bz2 acf-alpine-baselayout-4329b7b6da85440f537da8e4c1b9da1150912df3.tar.xz |
Added alpine-baselayout hostname and password edit.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1556 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'hostname-model.lua')
-rw-r--r-- | hostname-model.lua | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/hostname-model.lua b/hostname-model.lua index ba0c117..7d4238e 100644 --- a/hostname-model.lua +++ b/hostname-model.lua @@ -1,24 +1,30 @@ -- hostname model methods module (..., package.seeall) --- no initializer in model - use controller.init for that - +require("fs") get = function (self) local f = io.popen("/bin/hostname") local n = f:read("*a") or "unknown" f:close() - return (cfe{value=n, label="hostname"}) + return cfe({value=n, label="Hostname"}) +end + + +read_name = function () + return cfe({ type="group", value={hostname=get()}, label="Hostname" }) end +update_name = function(name) + local success = true -set = function (self, name) - local f = io.open ("/etc/hostname", "w") - if f then - f:write(name.value) + if success then + fs.write_file("/etc/hostname", name.value.hostname.value) + local f = io.popen("/bin/hostname -F /etc/hostname") f:close() + else + name.errtxt = "Failed to set hostname" end - f = io.popen("/bin/hostname -F /etc/hostname") - f:close() - return get(self) + + return name end |