projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libs/sys: extend luci.sys.hostname() to allow setting a new name
[project/luci.git]
/
libs
/
sys
/
luasrc
/
sys.lua
diff --git
a/libs/sys/luasrc/sys.lua
b/libs/sys/luasrc/sys.lua
index
a2c9a31
..
3e2ce7f
100644
(file)
--- a/
libs/sys/luasrc/sys.lua
+++ b/
libs/sys/luasrc/sys.lua
@@
-129,10
+129,16
@@
end
-- @return Table containing all variables if no variable name is given
getenv = posix.getenv
-- @return Table containing all variables if no variable name is given
getenv = posix.getenv
---- Determine the current hostname.
+--- Get or set the current hostname.
+-- @param String containing a new hostname to set (optional)
-- @return String containing the system hostname
-- @return String containing the system hostname
-function hostname()
- return posix.uname("%n")
+function hostname(newname)
+ if type(newname) == "string" and #newname > 0 then
+ luci.fs.writefile( "/proc/sys/kernel/hostname", newname .. "\n" )
+ return newname
+ else
+ return posix.uname("%n")
+ end
end
--- Returns the contents of a documented referred by an URL.
end
--- Returns the contents of a documented referred by an URL.