summaryrefslogtreecommitdiffstats
path: root/hostname-model.lua
blob: ba0c1178b05d70a31e743b4631ce827a04e4b199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- hostname model methods
module (..., package.seeall)

-- no initializer in model - use controller.init for that


get = function (self)
	local f = io.popen("/bin/hostname")
	local n = f:read("*a") or "unknown"
	f:close()
	return (cfe{value=n, label="hostname"})
end


set = function (self, name)
	local f = io.open ("/etc/hostname", "w")
	if f then
		f:write(name.value)
		f:close()
	end
	f =  io.popen("/bin/hostname -F /etc/hostname")
	f:close()
	return get(self)
end