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