summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/sys.luadoc
blob: c1e088eb2360016e7dcdffc38eec5a78c16a262b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
---[[
LuCI Linux and POSIX system utilities.
]]
module "luci.sys"

---[[
Execute a given shell command and return the error code

@class		function
@name		call
@param 		...		Command to call
@return		Error code of the command
]]

---[[
Execute a given shell command and capture its standard output

@class		function
@name		exec
@param command	Command to call
@return			String containing the return the output of the command
]]

---[[
Retrieve information about currently mounted file systems.

@class function
@name mounts
@return 	Table containing mount information
]]

---[[
Retrieve environment variables. If no variable is given then a table

containing the whole environment is returned otherwise this function returns
the corresponding string value for the given name or nil if no such variable
exists.
@class		function
@name		getenv
@param var	Name of the environment variable to retrieve (optional)
@return		String containing the value of the specified variable
@return		Table containing all variables if no variable name is given
]]

---[[
Get or set the current hostname.

@class function
@name hostname
@param		String containing a new hostname to set (optional)
@return		String containing the system hostname
]]

---[[
Returns the contents of a documented referred by an URL.

@class function
@name httpget
@param url	 The URL to retrieve
@param stream Return a stream instead of a buffer
@param target Directly write to target file name
@return		String containing the contents of given the URL
]]

---[[
Initiate a system reboot.

@class function
@name reboot
@return	Return value of os.execute()
]]

---[[
Retrieves the output of the "logread" command.

@class function
@name syslog
@return	String containing the current log buffer
]]

---[[
Retrieves the output of the "dmesg" command.

@class function
@name dmesg
@return	String containing the current log buffer
]]

---[[
Generates a random id with specified length.

@class function
@name uniqueid
@param bytes	Number of bytes for the unique id
@return		String containing hex encoded id
]]

---[[
Returns the current system uptime stats.

@class function
@name uptime
@return	String containing total uptime in seconds
]]

---[[
LuCI system utilities / network related functions.

@class	module
@name	luci.sys.net
]]

---[[
Returns a two-dimensional table of mac address hints.

@class function
@name net.mac_hints
@return  Table of table containing known hosts from various sources.
         Each entry contains the values in the following order:
         [ "mac", "name" ]
]]

---[[
Returns a two-dimensional table of IPv4 address hints.

@class function
@name net.ipv4_hints
@return  Table of table containing known hosts from various sources.
         Each entry contains the values in the following order:
         [ "ip", "name" ]
]]

---[[
Returns a two-dimensional table of IPv6 address hints.

@class function
@name net.ipv6_hints
@return  Table of table containing known hosts from various sources.
         Each entry contains the values in the following order:
         [ "ip", "name" ]
]]

---[[
Returns a two-dimensional table of host hints.

@class function
@name net.host_hints
@return  Table of table containing known hosts from various sources,
         indexed by mac address. Each subtable contains at least one
         of the fields "name", "ipv4" or "ipv6".
]]

---[[
Returns conntrack information

@class function
@name net.conntrack
@return	Table with the currently tracked IP connections
]]

---[[
Determine the names of available network interfaces.

@class function
@name net.devices
@return	Table containing all current interface names
]]

---[[
LuCI system utilities / process related functions.

@class	module
@name	luci.sys.process
]]

---[[
Get the current process id.

@class function
@name  process.info
@return	Number containing the current pid
]]

---[[
Retrieve information about currently running processes.

@class function
@name process.list
@return 	Table containing process information
]]

---[[
Set the gid of a process identified by given pid.

@class function
@name process.setgroup
@param gid	Number containing the Unix group id
@return		Boolean indicating successful operation
@return		String containing the error message if failed
@return		Number containing the error code if failed
]]

---[[
Set the uid of a process identified by given pid.

@class function
@name process.setuser
@param uid	Number containing the Unix user id
@return		Boolean indicating successful operation
@return		String containing the error message if failed
@return		Number containing the error code if failed
]]

---[[
Send a signal to a process identified by given pid.

@class function
@name  process.signal
@param pid	Number containing the process id
@param sig	Signal to send (default: 15 [SIGTERM])
@return		Boolean indicating successful operation
@return		Number containing the error code if failed
]]

---[[
Execute a process, optionally capturing stdio.

Executes the process specified by the given argv vector, e.g.
`{ "/bin/sh", "-c", "echo 1" }` and waits for it to terminate unless a true
value has been passed for the "nowait" parameter.

When a function value is passed for the stdout or stderr arguments, the passed
function is repeatedly called for each chunk read from the corresponding stdio
stream. The read data is passed as string containing at most 4096 bytes at a
time.

When a true, non-function value is passed for the stdout or stderr arguments,
the data of the corresponding stdio stream is read into an internal string
buffer and returned as "stdout" or "stderr" field respectively in the result
table.

When a true value is passed to the nowait parameter, the function does not
await process termination but returns as soon as all captured stdio streams
have been closed or - if no streams are captured - immediately after launching
the process.

@class function
@name  process.exec
@param commend	Table containing the argv vector to execute
@param stdout	Callback function or boolean to indicate capturing (optional)
@param stderr	Callback function or boolean to indicate capturing (optional)
@param nowait	Don't wait for process termination when true (optional)
@return		Table containing at least the fields "code" which holds the exit
            status of the invoked process or "-1" on error and "pid", which
            contains the process id assigned to the spawned process. When
            stdout and/or stderr capturing has been requested, it additionally
            contains "stdout" and "stderr" fields respectively, holding the
            captured stdio data as string.
]]

---[[
LuCI system utilities / user related functions.

@class	module
@name	luci.sys.user
]]

---[[
Retrieve user information for given uid.

@class		function
@name		getuser
@param uid	Number containing the Unix user id
@return		Table containing the following fields:
--				{ "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
]]

---[[
Retrieve the current user password hash.

@class function
@name user.getpasswd
@param username	String containing the username to retrieve the password for
@return			String containing the hash or nil if no password is set.
@return			Password database entry
]]

---[[
Test whether given string matches the password of a given system user.

@class function
@name user.checkpasswd
@param username	String containing the Unix user name
@param pass		String containing the password to compare
@return			Boolean indicating whether the passwords are equal
]]

---[[
Change the password of given user.

@class function
@name user.setpasswd
@param username	String containing the Unix user name
@param password	String containing the password to compare
@return			Number containing 0 on success and >= 1 on error
]]

---[[
LuCI system utilities / wifi related functions.

@class	module
@name	luci.sys.wifi
]]

---[[
Get wireless information for given interface.

@class function
@name wifi.getiwinfo
@param ifname        String containing the interface name
@return              A wrapped iwinfo object instance
]]

---[[
LuCI system utilities / init related functions.

@class	module
@name	luci.sys.init
]]

---[[
Get the names of all installed init scripts

@class function
@name init.names
@return	Table containing the names of all inistalled init scripts
]]

---[[
Get the index of he given init script

@class function
@name init.index
@param name	Name of the init script
@return		Numeric index value
]]

---[[
Test whether the given init script is enabled

@class function
@name init.enabled
@param name	Name of the init script
@return		Boolean indicating whether init is enabled
]]

---[[
Enable the given init script

@class function
@name init.enable
@param name	Name of the init script
@return		Boolean indicating success
]]

---[[
Disable the given init script

@class function
@name init.disable
@param name	Name of the init script
@return		Boolean indicating success
]]

---[[
Start the given init script

@class function
@name init.start
@param name	Name of the init script
@return		Boolean indicating success
]]

---[[
Stop the given init script

@class function
@name init.stop
@param name	Name of the init script
@return		Boolean indicating success
]]