Elektra  0.8.23
Plugin: blockresolver

The blockresolver can be used to only resolve a tagged block inside a configuration file.

Implementation details

blockresolver extracts the requested block from the configurations file and writes it into a temporary file. Afterwards Elektra will only work on the temporary file until kdbSet is called. On kdbSet the contents of the temporary file will be merged with parts outside of the requested block from the original file.

Usage

`kdb mount -R blockresolver /path/to/my/file /mountpoint -c identifier="identifier-tag"`

where identifier specifies the tag blockresolver will search for in the configuration file.

A block consists of 2 parts:

Limitations

Currently the identifier must be unique.

Example

1 # Backup-and-Restore:system/examples/blockresolver
2 
3 # create testfile
4 kdb set system/test/blockfile $(mktemp)
5 echo 'text' > $(kdb get system/test/blockfile)
6 echo 'more text' >> $(kdb get system/test/blockfile)
7 echo 'some more text' >> $(kdb get system/test/blockfile)
8 echo '>>> block config start' >> $(kdb get system/test/blockfile)
9 echo '[section1]' >> $(kdb get system/test/blockfile)
10 echo 'key1 = val1' >> $(kdb get system/test/blockfile)
11 echo '[section2]' >> $(kdb get system/test/blockfile)
12 echo 'key2 = val2' >> $(kdb get system/test/blockfile)
13 echo '>>> block config stop' >> $(kdb get system/test/blockfile)
14 echo 'text again' >> $(kdb get system/test/blockfile)
15 echo 'and more text' >> $(kdb get system/test/blockfile)
16 echo 'text' >> $(kdb get system/test/blockfile)
17 
18 sudo kdb mount -R blockresolver $(kdb get system/test/blockfile) system/examples/blockresolver -c identifier=">>> block config" ini
19 
20 # check testfile
21 cat $(kdb get system/test/blockfile)
22 #> text
23 #> more text
24 #> some more text
25 #> >>> block config start
26 #> [section1]
27 #> key1 = val1
28 #> [section2]
29 #> key2 = val2
30 #> >>> block config stop
31 #> text again
32 #> and more text
33 #> text
34 
35 # only the block between the tags is read!
36 kdb export system/examples/blockresolver ini
37 #> [section1]
38 #> key1 = val1
39 #> [section2]
40 #> key2 = val2
41 
42 # add a new key to the resolved block
43 kdb set system/examples/blockresolver/section1/key12 val12
44 
45 cat $(kdb get system/test/blockfile)
46 #> text
47 #> more text
48 #> some more text
49 #> >>> block config start
50 #> [section1]
51 #> key1 = val1
52 #> key12 = val12
53 #> [section2]
54 #> key2 = val2
55 #> >>> block config stop
56 #> text again
57 #> and more text
58 #> text
59 
60 # cleanup
61 kdb rm -r system/examples/blockresolver
62 rm $(kdb get system/test/blockfile)
63 kdb rm system/test/blockfile
64 sudo kdb umount system/examples/blockresolver