docs: add very basic ubus docs
[web.git] / docs / ubus.txt
1 include::header.txt[]
2
3 == uBus - IPC/RPC
4
5 uBus is the interconnect system used by most service running on a _LEDE_ setup.
6 Service can connect to the bus and provide methods that can be called by other services or clients.
7
8 There is a CLI that can be used to communicate with services on the bus.
9
10 ----
11 root@lede:/# ubus
12 Usage: ubus [<options>] <command> [arguments...]
13 Options:
14 -s <socket>: Set the unix domain socket to connect to
15 -t <timeout>: Set the timeout (in seconds) for a command to complete
16 -S: Use simplified output (for scripts)
17 -v: More verbose output
18
19 Commands:
20 - list [<path>] List objects
21 - call <path> <method> [<message>] Call an object method
22 - listen [<path>...] Listen for events
23 - send <type> [<message>] Send an event
24 - wait_for <object> [<object>...] Wait for multiple objects to appear on ubus
25 ----
26
27 To find out which services are currently running on the bus simply use the list command. This will show a complete list.
28
29 ----
30 root@lede:/# ubus list
31 dhcp
32 log
33 network
34 network.device
35 network.interface
36 network.interface.loopback
37 network.interface.wan
38 network.interface.wan6
39 network.wireless
40 service
41 system
42 ----
43
44 To find out which methods a specific service provides also use the list command but add a few more parameters to see a complete list
45
46 ----
47 root@OpenWrt:/# ubus -v list system
48 'system' @6b093875
49 "board":{}
50 "info":{}
51 "upgrade":{}
52 "watchdog":{"frequency":"Integer","timeout":"Integer","stop":"Boolean"}
53 "signal":{"pid":"Integer","signum":"Integer"}
54 ----
55
56 You can now call a remote method and receive a reply. A reply may be a simple integer return code or a more complete reply. Internally the bus uses a blob format, the CLI conveniently converts this to JSON.
57
58 ----
59 root@lede:/# ubus call system board
60 {
61 "kernel": "4.4.6",
62 "hostname": "lede",
63 "system": "MIPS Malta",
64 "release": {
65 "distribution": "LEDE",
66 "version": "HEAD",
67 "revision": "3",
68 "codename": "designated_driver",
69 "target": "malta\/le",
70 "description": "LEDE Designated Driver 3"
71 }
72 }
73 ----
74
75 You can call a method and pass it some parameters by simply appending a JSON structure to the CLI command.
76 ----
77 root@lede:/# ubus call system signal '{ "pid": 123, "signum": 9 }'
78 root@lede:/# echo $?
79 0
80 ----
81
82