diff options
Diffstat (limited to 'libs/sys/luasrc')
-rw-r--r-- | libs/sys/luasrc/sys.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index a2c9a3111..3e2ce7f31 100644 --- 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 ---- 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 -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. |