User Tools

Site Tools


midge:kdb

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

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

# 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 }

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

# kdb create

set

# 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

get

# kdb get sys_iface_eth0_ipaddr
192.168.0.1

# kdb get sys_iface_eth0_netmask
255.255.255.0

list

# 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

sublist

# 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"

variable evaluation

# 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

keylist

# kdb kls sys_iface_eth0
sys_iface_eth0_desc
sys_iface_eth0_ipaddr
sys_iface_eth0_netmask
sys_iface_eth0_broadcast

wildard set

Currently only asterisk * is supported.

# kdb wset sys_iface_*ip*=10.1.1.1

wildcard rm

<code> # kdb wrm

midge/kdb.txt · Last modified: 2018/04/09 15:36 (external edit)