luci-0.8: merge r4218 and r4221
This commit is contained in:
parent
8ecde162ba
commit
6067bc9f52
1 changed files with 11 additions and 4 deletions
|
@ -35,7 +35,8 @@ luci.util = require "luci.util"
|
||||||
luci.fs = require "luci.fs"
|
luci.fs = require "luci.fs"
|
||||||
luci.ip = require "luci.ip"
|
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,11 +130,17 @@ end
|
||||||
-- @return Table containing all variables if no variable name is given
|
-- @return Table containing all variables if no variable name is given
|
||||||
getenv = posix.getenv
|
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()
|
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")
|
return posix.uname("%n")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the contents of a documented referred by an URL.
|
--- Returns the contents of a documented referred by an URL.
|
||||||
-- @param url The URL to retrieve
|
-- @param url The URL to retrieve
|
||||||
|
|
Loading…
Reference in a new issue