2
0

sys.luadoc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. ---[[
  2. LuCI Linux and POSIX system utilities.
  3. ]]
  4. module "luci.sys"
  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 a two-dimensional table of host hints.
  122. @class function
  123. @name net.host_hints
  124. @return Table of table containing known hosts from various sources,
  125. indexed by mac address. Each subtable contains at least one
  126. of the fields "name", "ipv4" or "ipv6".
  127. ]]
  128. ---[[
  129. Returns conntrack information
  130. @class function
  131. @name net.conntrack
  132. @return Table with the currently tracked IP connections
  133. ]]
  134. ---[[
  135. Determine the names of available network interfaces.
  136. @class function
  137. @name net.devices
  138. @return Table containing all current interface names
  139. ]]
  140. ---[[
  141. Return information about available network interfaces.
  142. @class function
  143. @name net.deviceinfo
  144. @return Table containing all current interface names and their information
  145. ]]
  146. ---[[
  147. Returns the current kernel routing table entries.
  148. @class function
  149. @name net.routes
  150. @return Table of tables with properties of the corresponding routes.
  151. -- The following fields are defined for route entry tables:
  152. -- { "dest", "gateway", "metric", "refcount", "usecount", "irtt",
  153. -- "flags", "device" }
  154. ]]
  155. ---[[
  156. Returns the current ipv6 kernel routing table entries.
  157. @class function
  158. @name net.routes6
  159. @return Table of tables with properties of the corresponding routes.
  160. -- The following fields are defined for route entry tables:
  161. -- { "source", "dest", "nexthop", "metric", "refcount", "usecount",
  162. -- "flags", "device" }
  163. ]]
  164. ---[[
  165. Tests whether the given host responds to ping probes.
  166. @class function
  167. @name net.pingtest
  168. @param host String containing a hostname or IPv4 address
  169. @return Number containing 0 on success and >= 1 on error
  170. ]]
  171. ---[[
  172. LuCI system utilities / process related functions.
  173. @class module
  174. @name luci.sys.process
  175. ]]
  176. ---[[
  177. Get the current process id.
  178. @class function
  179. @name process.info
  180. @return Number containing the current pid
  181. ]]
  182. ---[[
  183. Retrieve information about currently running processes.
  184. @class function
  185. @name process.list
  186. @return Table containing process information
  187. ]]
  188. ---[[
  189. Set the gid of a process identified by given pid.
  190. @class function
  191. @name process.setgroup
  192. @param gid Number containing the Unix group id
  193. @return Boolean indicating successful operation
  194. @return String containing the error message if failed
  195. @return Number containing the error code if failed
  196. ]]
  197. ---[[
  198. Set the uid of a process identified by given pid.
  199. @class function
  200. @name process.setuser
  201. @param uid Number containing the Unix user id
  202. @return Boolean indicating successful operation
  203. @return String containing the error message if failed
  204. @return Number containing the error code if failed
  205. ]]
  206. ---[[
  207. Send a signal to a process identified by given pid.
  208. @class function
  209. @name process.signal
  210. @param pid Number containing the process id
  211. @param sig Signal to send (default: 15 [SIGTERM])
  212. @return Boolean indicating successful operation
  213. @return Number containing the error code if failed
  214. ]]
  215. ---[[
  216. LuCI system utilities / user related functions.
  217. @class module
  218. @name luci.sys.user
  219. ]]
  220. ---[[
  221. Retrieve user informations for given uid.
  222. @class function
  223. @name getuser
  224. @param uid Number containing the Unix user id
  225. @return Table containing the following fields:
  226. -- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
  227. ]]
  228. ---[[
  229. Retrieve the current user password hash.
  230. @class function
  231. @name user.getpasswd
  232. @param username String containing the username to retrieve the password for
  233. @return String containing the hash or nil if no password is set.
  234. @return Password database entry
  235. ]]
  236. ---[[
  237. Test whether given string matches the password of a given system user.
  238. @class function
  239. @name user.checkpasswd
  240. @param username String containing the Unix user name
  241. @param pass String containing the password to compare
  242. @return Boolean indicating wheather the passwords are equal
  243. ]]
  244. ---[[
  245. Change the password of given user.
  246. @class function
  247. @name user.setpasswd
  248. @param username String containing the Unix user name
  249. @param password String containing the password to compare
  250. @return Number containing 0 on success and >= 1 on error
  251. ]]
  252. ---[[
  253. LuCI system utilities / wifi related functions.
  254. @class module
  255. @name luci.sys.wifi
  256. ]]
  257. ---[[
  258. Get wireless information for given interface.
  259. @class function
  260. @name wifi.getiwinfo
  261. @param ifname String containing the interface name
  262. @return A wrapped iwinfo object instance
  263. ]]
  264. ---[[
  265. LuCI system utilities / init related functions.
  266. @class module
  267. @name luci.sys.init
  268. ]]
  269. ---[[
  270. Get the names of all installed init scripts
  271. @class function
  272. @name init.names
  273. @return Table containing the names of all inistalled init scripts
  274. ]]
  275. ---[[
  276. Get the index of he given init script
  277. @class function
  278. @name init.index
  279. @param name Name of the init script
  280. @return Numeric index value
  281. ]]
  282. ---[[
  283. Test whether the given init script is enabled
  284. @class function
  285. @name init.enabled
  286. @param name Name of the init script
  287. @return Boolean indicating whether init is enabled
  288. ]]
  289. ---[[
  290. Enable the given init script
  291. @class function
  292. @name init.enable
  293. @param name Name of the init script
  294. @return Boolean indicating success
  295. ]]
  296. ---[[
  297. Disable the given init script
  298. @class function
  299. @name init.disable
  300. @param name Name of the init script
  301. @return Boolean indicating success
  302. ]]
  303. ---[[
  304. Start the given init script
  305. @class function
  306. @name init.start
  307. @param name Name of the init script
  308. @return Boolean indicating success
  309. ]]
  310. ---[[
  311. Stop the given init script
  312. @class function
  313. @name init.stop
  314. @param name Name of the init script
  315. @return Boolean indicating success
  316. ]]