Elektra  0.8.19
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 #
6 $ echo "text" > /tmp/test.block
7 $ echo "more text" >> /tmp/test.block
8 $ echo "some more text" >> /tmp/test.block
9 $ echo ">>> block config start" >> /tmp/test.block
10 $ echo "[section1]" >> /tmp/test.block
11 $ echo "key1 = val1" >> /tmp/test.block
12 $ echo "[section2]" >> /tmp/test.block
13 $ echo "key2 = val2" >> /tmp/test.block
14 $ echo ">>> block config stop" >> /tmp/test.block
15 $ echo "text again" >> /tmp/test.block
16 $ echo "and more text" >> /tmp/test.block
17 $ echo "text" >> /tmp/test.block
18 #
19 # check testfile
20 #
21 $ cat /tmp/test.block
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 #
37 kdb export system/examples/blockresolver ini
38 [section1]
39 key1 = val1
40 [section2]
41 key2 = val2
42 #
43 # add a new key to the resolved block
44 #
45 kdb set system/examples/blockresolver/section1/key12 val12
46 #
47 $ cat /tmp/test.block
48 text
49 more text
50 some more text
51 >>> block config start
52 [section1]
53 key1 = val1
54 key12 = val12
55 [section2]
56 key2 = val2
57 >>> block config stop
58 text again
59 and more text
60 text
61 #
62 # cleanup
63 #
64 kdb rm -r system/examples/blockresolver
65 sudo kdb umount system/examples/blockresolver