sys.luadoc 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. ---[[
  2. LuCI Linux and POSIX system utilities.
  3. module "luci.sys"
  4. ]]
  5. ---[[
  6. Execute a given shell command and return the error code
  7. @class function
  8. @name call
  9. @param ... Command to call
  10. @return Error code of the command
  11. ]]
  12. ---[[
  13. Execute a given shell command and capture its standard output
  14. @class function
  15. @name exec
  16. @param command Command to call
  17. @return String containg the return the output of the command
  18. ]]
  19. ---[[
  20. Retrieve information about currently mounted file systems.
  21. @class function
  22. @name mounts
  23. @return Table containing mount information
  24. ]]
  25. ---[[
  26. Retrieve environment variables. If no variable is given then a table
  27. containing the whole environment is returned otherwise this function returns
  28. the corresponding string value for the given name or nil if no such variable
  29. exists.
  30. @class function
  31. @name getenv
  32. @param var Name of the environment variable to retrieve (optional)
  33. @return String containg the value of the specified variable
  34. @return Table containing all variables if no variable name is given
  35. ]]
  36. ---[[
  37. Get or set the current hostname.
  38. @class function
  39. @name hostname
  40. @param String containing a new hostname to set (optional)
  41. @return String containing the system hostname
  42. ]]
  43. ---[[
  44. Returns the contents of a documented referred by an URL.
  45. @class function
  46. @name httpget
  47. @param url The URL to retrieve
  48. @param stream Return a stream instead of a buffer
  49. @param target Directly write to target file name
  50. @return String containing the contents of given the URL
  51. ]]
  52. ---[[
  53. Initiate a system reboot.
  54. @class function
  55. @name reboot
  56. @return Return value of os.execute()
  57. ]]
  58. ---[[
  59. Retrieves the output of the "logread" command.
  60. @class function
  61. @name syslog
  62. @return String containing the current log buffer
  63. ]]
  64. ---[[
  65. Retrieves the output of the "dmesg" command.
  66. @class function
  67. @name dmesg
  68. @return String containing the current log buffer
  69. ]]
  70. ---[[
  71. Generates a random id with specified length.
  72. @class function
  73. @name uniqueid
  74. @param bytes Number of bytes for the unique id
  75. @return String containing hex encoded id
  76. ]]
  77. ---[[
  78. Returns the current system uptime stats.
  79. @class function
  80. @name uptime
  81. @return String containing total uptime in seconds
  82. ]]
  83. ---[[
  84. LuCI system utilities / network related functions.
  85. @class module
  86. @name luci.sys.net
  87. ]]
  88. ---[[
  89. Returns the current arp-table entries as two-dimensional table.
  90. @class function
  91. @name net.arptable
  92. @return Table of table containing the current arp entries.
  93. -- The following fields are defined for arp entry objects:
  94. -- { "IP address", "HW address", "HW type", "Flags", "Mask", "Device" }
  95. ]]
  96. ---[[
  97. Returns a two-dimensional table of mac address hints.
  98. @class function
  99. @name net.mac_hints
  100. @return Table of table containing known hosts from various sources.
  101. Each entry contains the values in the following order:
  102. [ "mac", "name" ]
  103. ]]
  104. ---[[
  105. Returns a two-dimensional table of IPv4 address hints.
  106. @class function
  107. @name net.ipv4_hints
  108. @return Table of table containing known hosts from various sources.
  109. Each entry contains the values in the following order:
  110. [ "ip", "name" ]
  111. ]]
  112. ---[[
  113. Returns a two-dimensional table of IPv6 address hints.
  114. @class function
  115. @name net.ipv6_hints
  116. @return Table of table containing known hosts from various sources.
  117. Each entry contains the values in the following order:
  118. [ "ip", "name" ]
  119. ]]
  120. ---[[
  121. Returns conntrack information
  122. @class function
  123. @name net.conntrack
  124. @return Table with the currently tracked IP connections
  125. ]]
  126. ---[[
  127. Determine the names of available network interfaces.
  128. @class function
  129. @name net.devices
  130. @return Table containing all current interface names
  131. ]]
  132. ---[[
  133. Return information about available network interfaces.
  134. @class function
  135. @name net.deviceinfo
  136. @return Table containing all current interface names and their information
  137. ]]
  138. ---[[
  139. Returns the current kernel routing table entries.
  140. @class function
  141. @name net.routes
  142. @return Table of tables with properties of the corresponding routes.
  143. -- The following fields are defined for route entry tables:
  144. -- { "dest", "gateway", "metric", "refcount", "usecount", "irtt",
  145. -- "flags", "device" }
  146. ]]
  147. ---[[
  148. Returns the current ipv6 kernel routing table entries.
  149. @class function
  150. @name net.routes6
  151. @return Table of tables with properties of the corresponding routes.
  152. -- The following fields are defined for route entry tables:
  153. -- { "source", "dest", "nexthop", "metric", "refcount", "usecount",
  154. -- "flags", "device" }
  155. ]]
  156. ---[[
  157. Tests whether the given host responds to ping probes.
  158. @class function
  159. @name net.pingtest
  160. @param host String containing a hostname or IPv4 address
  161. @return Number containing 0 on success and >= 1 on error
  162. ]]
  163. ---[[
  164. LuCI system utilities / process related functions.
  165. @class module
  166. @name luci.sys.process
  167. ]]
  168. ---[[
  169. Get the current process id.
  170. @class function
  171. @name process.info
  172. @return Number containing the current pid
  173. ]]
  174. ---[[
  175. Retrieve information about currently running processes.
  176. @class function
  177. @name process.list
  178. @return Table containing process information
  179. ]]
  180. ---[[
  181. Set the gid of a process identified by given pid.
  182. @class function
  183. @name process.setgroup
  184. @param gid Number containing the Unix group id
  185. @return Boolean indicating successful operation
  186. @return String containing the error message if failed
  187. @return Number containing the error code if failed
  188. ]]
  189. ---[[
  190. Set the uid of a process identified by given pid.
  191. @class function
  192. @name process.setuser
  193. @param uid Number containing the Unix user id
  194. @return Boolean indicating successful operation
  195. @return String containing the error message if failed
  196. @return Number containing the error code if failed
  197. ]]
  198. ---[[
  199. Send a signal to a process identified by given pid.
  200. @class function
  201. @name process.signal
  202. @param pid Number containing the process id
  203. @param sig Signal to send (default: 15 [SIGTERM])
  204. @return Boolean indicating successful operation
  205. @return Number containing the error code if failed
  206. ]]
  207. ---[[
  208. LuCI system utilities / user related functions.
  209. @class module
  210. @name luci.sys.user
  211. ]]
  212. ---[[
  213. Retrieve user informations for given uid.
  214. @class function
  215. @name getuser
  216. @param uid Number containing the Unix user id
  217. @return Table containing the following fields:
  218. -- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
  219. ]]
  220. ---[[
  221. Retrieve the current user password hash.
  222. @class function
  223. @name user.getpasswd
  224. @param username String containing the username to retrieve the password for
  225. @return String containing the hash or nil if no password is set.
  226. @return Password database entry
  227. ]]
  228. ---[[
  229. Test whether given string matches the password of a given system user.
  230. @class function
  231. @name user.checkpasswd
  232. @param username String containing the Unix user name
  233. @param pass String containing the password to compare
  234. @return Boolean indicating wheather the passwords are equal
  235. ]]
  236. ---[[
  237. Change the password of given user.
  238. @class function
  239. @name user.setpasswd
  240. @param username String containing the Unix user name
  241. @param password String containing the password to compare
  242. @return Number containing 0 on success and >= 1 on error
  243. ]]
  244. ---[[
  245. LuCI system utilities / wifi related functions.
  246. @class module
  247. @name luci.sys.wifi
  248. ]]
  249. ---[[
  250. Get wireless information for given interface.
  251. @class function
  252. @name wifi.getiwinfo
  253. @param ifname String containing the interface name
  254. @return A wrapped iwinfo object instance
  255. ]]
  256. ---[[
  257. LuCI system utilities / init related functions.
  258. @class module
  259. @name luci.sys.init
  260. ]]
  261. ---[[
  262. Get the names of all installed init scripts
  263. @class function
  264. @name init.names
  265. @return Table containing the names of all inistalled init scripts
  266. ]]
  267. ---[[
  268. Get the index of he given init script
  269. @class function
  270. @name init.index
  271. @param name Name of the init script
  272. @return Numeric index value
  273. ]]
  274. ---[[
  275. Test whether the given init script is enabled
  276. @class function
  277. @name init.enabled
  278. @param name Name of the init script
  279. @return Boolean indicating whether init is enabled
  280. ]]
  281. ---[[
  282. Enable the given init script
  283. @class function
  284. @name init.enable
  285. @param name Name of the init script
  286. @return Boolean indicating success
  287. ]]
  288. ---[[
  289. Disable the given init script
  290. @class function
  291. @name init.disable
  292. @param name Name of the init script
  293. @return Boolean indicating success
  294. ]]
  295. ---[[
  296. Start the given init script
  297. @class function
  298. @name init.start
  299. @param name Name of the init script
  300. @return Boolean indicating success
  301. ]]
  302. ---[[
  303. Stop the given init script
  304. @class function
  305. @name init.stop
  306. @param name Name of the init script
  307. @return Boolean indicating success
  308. ]]