Elektra
0.9.4
|
Following the elektra keyname convention application configurations are stored under /sw/org/myapp/#
and /sw/org/myapp/#0/current
is the profile to be used. The profile
plugin provides an easy way to switch configuration profiles.
The key /sw/org/myapp/#0/profile
defines what profile should be used as current
, e.g. /sw/org/myapp/#0/profile = myprofile
. If a key /sw/org/myapp/#0/myprofile/key
is found and no key /sw/org/myapp/#0/current/key
exists an override key will be created linking /sw/org/myapp/#0/currrent/key
to /sw/org/myapp/#0/myapp/key
If neither /sw/org/myapp/#0/current/key
nor /sw/org/myapp/#0/myprofile/key
is found, but /sw/org/myapp/#0/%/key
, /sw/org/myapp/#0/current/key
will be linked to /sw/org/myapp/#0/%/key
.
So a cascading lookup will automatically implement following preferences (next to the namespace preferences):
current
profile
%
fallback profileSuppose we have the configuration file profile.ini
in ~/.config
:
Then we simply mount it without the profile plugin:
But we have to make sure that the profile plugin is mounted globally:
Then we can access /sw/org/myapp/#0
in a profile-aware way:
As we can see with the -v
option, we will fetch keys from our myprofile
even though we request current
:
To switch profile we simply have to set one key:
Usually, this will be done via commandline by setting proc:/sw/org/myapp/#0/profile
.