User Tools

Site Tools


midge:kdb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

midge:kdb [2018/04/09 15:36] (current)
Line 1: Line 1:
 +===== KDB =====
  
 +==== What is it ? ====
 +**kdb** is a registry-like data storage for shell scripts on embeded systems. **kdb** is a part of **webface** project.
 +
 +==== Licence ====
 + GNU GPL2
 +
 +==== Download ====
 +  * http://​midge.vlad.org.ua/​svn/​trunk/​openwrt-midge/​package/​webface/​kdb.c
 +
 +==== Files ====
 +By default **kdb** uses **~/.kdb** for regular user, and **/​etc/​kdb** for root user. If **KDB** variable is in the environment when kdb uses it.
 +
 +==== Usage ====
 +<​code>​
 +# kdb   
 +Usage: kdb [OPTIONS] ARG [: ARG] 
 +where  OPTIONS:= l|q|qq|e|c
 +       ARG := { set wildcardkey=value |
 +        rm wildcardkey | del wildcardkey |
 +        isset key |
 +        list [key] |ls [key] |
 +        slist key | sls key |
 +        klist key | kls key |
 +        listrm key | lrm key |
 +        listadd key_=value | ladd key_=value |
 +        rename oldkey newkey | rn oldkey newkey |
 +        create [filename] |
 +        import [filename] |
 +        edit }
 +</​code>​
 +
 +==== Options ====
 +  * **-l** prepend **'​local'​** for listing commands
 +  * **-q** quoting by "
 +  * **-qq** quoting by '
 +  * **-e** prepend with **'​export'​** for listing commands
 +  * **-c** additionally print "​kdb_lines_count=X",​ where X - output lines
 +
 +==== Wildcard matching ====
 +  * ** *  ** - Matches any string, including the null string
 +
 +==== Examples ====
 +
 +=== create ===
 +<​code>​
 +# kdb create
 +</​code>​
 +
 +=== set ===
 +<​code>​
 +# kdb set sys_iface_eth0_desc="​Local Area Network"​
 +# kdb set sys_iface_eth0_ipaddr=192.168.0.1
 +# kdb set sys_iface_eth0_netmask=255.255.255.0
 +# kdb set sys_iface_eth0_broadcast=192.168.0.255
 +# kdb set sys_iface_eth1_ipaddr=192.168.1.1
 +# kdb set sys_iface_eth1_netmask=255.255.255.0
 +</​code>​
 +
 +=== get ===
 +<​code>​
 +# kdb get sys_iface_eth0_ipaddr
 +192.168.0.1
 +
 +# kdb get sys_iface_eth0_netmask
 +255.255.255.0
 +</​code>​
 +
 +=== list ===
 +<​code>​
 +# kdb ls
 +sys_iface_eth0_desc=Local Area Network
 +sys_iface_eth0_ipaddr=192.168.0.1
 +sys_iface_eth0_netmask=255.255.255.0
 +sys_iface_eth0_broadcast=192.168.0.255
 +sys_iface_eth1_ipaddr=192.168.1.1
 +sys_iface_eth1_netmask=255.255.255.0
 +
 +# kdb -q ls sys_iface_eth0
 +sys_iface_eth0_desc="​Local Area Network"​
 +sys_iface_eth0_ipaddr="​192.168.0.1"​
 +sys_iface_eth0_netmask="​255.255.255.0"​
 +sys_iface_eth0_broadcast="​192.168.0.255"​
 +
 +# kdb ls sys_iface_eth0_ipaddr
 +sys_iface_eth0_ipaddr=192.168.0.1
 +</​code>​
 +
 +
 +=== sublist ===
 +<​code>​
 +# kdb -q sls sys_iface_eth0_
 +desc="​Local Area Network"​
 +ipaddr="​192.168.0.1"​
 +netmask="​255.255.255.0"​
 +broadcast="​192.168.0.255"​
 +</​code>​
 +
 +=== variable evaluation ===
 +<​code>​
 +# eval `kdb -q ls sys_iface_eth0_`
 +# echo $sys_iface_eth0_ipaddr
 +192.168.0.1
 +
 +# iface=eth0
 +# eval "​ipaddr=\$sys_iface_${iface}_ipaddr"​
 +# echo $ipaddr
 +192.168.0.1
 +
 +</​code>​
 +
 +=== keylist ===
 +<​code>​
 +# kdb kls sys_iface_eth0
 +sys_iface_eth0_desc
 +sys_iface_eth0_ipaddr
 +sys_iface_eth0_netmask
 +sys_iface_eth0_broadcast
 +</​code>​
 +
 +=== wildard set ===
 +Currently only asterisk * is supported.
 +<​code>​
 +# kdb wset sys_iface_*ip*=10.1.1.1
 +</​code>​
 +
 +
 +=== wildcard rm ===
 +<​code>​
 +# kdb wrm 
midge/kdb.txt · Last modified: 2018/04/09 15:36 (external edit)