projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8ecde16
)
luci-0.8: merge r4218 and r4221
author
Jo-Philipp Wich
<jow@openwrt.org>
Sat, 9 May 2009 15:52:23 +0000
(15:52 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Sat, 9 May 2009 15:52:23 +0000
(15:52 +0000)
libs/sys/luasrc/sys.lua
patch
|
blob
|
history
diff --git
a/libs/sys/luasrc/sys.lua
b/libs/sys/luasrc/sys.lua
index
a2c9a31
..
1ecd5d2
100644
(file)
--- a/
libs/sys/luasrc/sys.lua
+++ b/
libs/sys/luasrc/sys.lua
@@
-35,7
+35,8
@@
luci.util = require "luci.util"
luci.fs = require "luci.fs"
luci.ip = require "luci.ip"
luci.fs = require "luci.fs"
luci.ip = require "luci.ip"
-local tonumber, ipairs, pairs, pcall = tonumber, ipairs, pairs, pcall
+local tonumber, ipairs, pairs, pcall, type =
+ tonumber, ipairs, pairs, pcall, type
--- LuCI Linux and POSIX system utilities.
--- LuCI Linux and POSIX system utilities.
@@
-129,10
+130,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.