OpenWrt - rpcd
2016-06-16 06:59
447 查看
https://wiki.openwrt.org/doc/techref/rpcd
通过使用rpcd的可执行插件功能,可以通过ubus曝光shell描述符功能。可执行文件保存在
This will create new ubus functions which then can be used (after restarting rpcd):
这将创建新的ubus函数,然后可以运行它们(重新启动rpcd):
On startup rpcd will call all executables in /usr/libexec/rpcd/ with argv[1] set to “list”. For a plugin, which responds with a valid list of methods and signatures, ubus method with appropriate arguments will be created. When a method provided by the plugin is about to be invoked, rpcd calls the binary with argv[1] set to “call” and argv[2] set to the invoked method name. The actual data is then sent by the ubus client via stdin.
rpcd启动将调用所有在
The method signature is a simple object containing key:value pairs. The argument type is inferred from the value. If the value is a string (regardless of the contents) it is registered as string, if the value is a bool true or false, its registered as bool, if the value is an integer, it is registered as either int8, int16, int32 or int64 depending on the value (“foo”: 16 will be INT16, “foo”: 64 will be INT64, “foo”: 8 will be INT8 and everything else will be INT32).
方法标签是一个简单的对象,包含键:value pairs。参数类型由值推测。如果值是一个字符串(不理会内容),它的寄存器作为字符串,如果值是一个bool true/false,它的寄存器是bool,如果值是一个integer,它的寄存器既可以是int8,int16,int32,也可以是int64,依赖值(“foo”:16是INT16,“foo”:64是INT64,“foo”:8是INT8其它的是INT32)。
It is enough to issue ‘/etc/init.d/rpcd reload’ to make it pick up new plugin executables, that way one does not lose active sessions.
执行
rpcd (OpenWrt ubus RPC backend server)//Openwrt ubus RPC后端服务
The code is published under ISC and can be found via git atplugin executables //可执行插件
It is possible to expose shell script functionality over ubus by using rpcd plugin executables functionality. Executables stored in /usr/libexec/rpcd/ directory will be runned by rpcd. Lets look at the following example:通过使用rpcd的可执行插件功能,可以通过ubus曝光shell描述符功能。可执行文件保存在
/usr/libexec/rpcd目录下,rpcd将运行他么。让我们看下面的例子:
$ cat << EOF > /usr/libexec/rpcd/foo #!/bin/sh case "$1" in list) echo '{ "bar": { "arg1": true, "arg2": 32, "arg3": "str" }, "toto": { } }' ;; call) case "$2" in bar) # read the arguments read input; # optionally log the call logger -t "foo" "call" "$2" "$input" # return json object or an array echo '{ "hello": "world" }' ;; toto) # return json object or an array echo '[ "item1", "item2", "item3" ]' ;; esac ;; esac EOF $ chmod +x /usr/libexec/rpcd/foo
This will create new ubus functions which then can be used (after restarting rpcd):
这将创建新的ubus函数,然后可以运行它们(重新启动rpcd):
$ ubus list -v ... 'foo' @686f0592 "bar":{"arg1":"Boolean","arg2":"Integer","arg3":"String"} "toto":{} ... $ ubus call -S foo bar '{"arg1": true }' {{"hello":"world"}} $ ubus call -S foo toto {["item1","item2","item3"]}
On startup rpcd will call all executables in /usr/libexec/rpcd/ with argv[1] set to “list”. For a plugin, which responds with a valid list of methods and signatures, ubus method with appropriate arguments will be created. When a method provided by the plugin is about to be invoked, rpcd calls the binary with argv[1] set to “call” and argv[2] set to the invoked method name. The actual data is then sent by the ubus client via stdin.
rpcd启动将调用所有在
/usr/libexec/rpcd下所有可执行程序,使用argv[1]设置一个’list’。对于一个插件,相应一个有效的方法列表和标签,ubus方法用一个创建的合适的参数。当一个插件提供的方法被调用,rpcd用二进制,用argv[1]设置”call”,argv[2]设置调用方法名。激活的数据被ubus客户机发送到stdin。
The method signature is a simple object containing key:value pairs. The argument type is inferred from the value. If the value is a string (regardless of the contents) it is registered as string, if the value is a bool true or false, its registered as bool, if the value is an integer, it is registered as either int8, int16, int32 or int64 depending on the value (“foo”: 16 will be INT16, “foo”: 64 will be INT64, “foo”: 8 will be INT8 and everything else will be INT32).
方法标签是一个简单的对象,包含键:value pairs。参数类型由值推测。如果值是一个字符串(不理会内容),它的寄存器作为字符串,如果值是一个bool true/false,它的寄存器是bool,如果值是一个integer,它的寄存器既可以是int8,int16,int32,也可以是int64,依赖值(“foo”:16是INT16,“foo”:64是INT64,“foo”:8是INT8其它的是INT32)。
It is enough to issue ‘/etc/init.d/rpcd reload’ to make it pick up new plugin executables, that way one does not lose active sessions.
执行
/etc/init.d/rpcd reload可以开始执行新的可执行插件,这个方法不会丢掉激活的部分。
相关文章推荐
- LeetCode 354. Russian Doll Envelopes(信封包装)
- VS2010 调试基于ARM的linux程序方法
- curl
- linux查检安装些什么软件
- CentOS, Fedora, or Red Hat一行命令安装apache + mysql + php 及各种依赖库
- ANSI C限制 和 POSIX限制
- Linux系统之文件类型
- 理解RESTFul架构
- 关于Linux中的补丁命令diff和patch
- Ubuntu 16.04 下修改免安裝版tomcat的內存大小
- Linux系统下的/etc/nsswitch.conf文件
- Apache安装
- 关于解决/lib/ld-linux.so.2: bad ELF interpreter:
- Hadoop-2.7.2伪分布式集群搭建
- 高可用集群HA架构搭建
- Error starting static Resources java.lang.IllegalArgumentException: Document base D:\Program Files\apache-tomcat-xxx\webapps\xxx does not exist or is not a readable directory
- PopupWindow响应返回键的问题
- Nginx/LVS/HAProxy负载均衡软件的优缺点详解
- DBCP,C3P0,Tomcat_JDBC 性能及稳定性测试
- linux-windows碎片问题