Is there a dynamic/on-the-fly textfile template engine that works on the filesystem level, e.g. via fuse, in a similar fashion to web-server html template engines?

Imagine you have, e.g. a /etc/hostapd/hostapd.conf AP configuration file like so

# On-the-fly AP configuration for any interface

Now I mount the /etc/hostapd/ folder (or even just a single file) with my cool (fuse) fs to /etc/hostapd-dyn:

mount -t template-fuse /etc/hostapd /etc/hostapd-dyn

And the file /etc/hostapd-dyn/hostapd.conf/dev=wlp0s2 would now contain

# On-the-fly AP configuration for any interface

Such a fs would allow to have dynamic configuration files where you might not even know in advance some of its values but you don't have the possibility to create the file dynamically by piping it through a file preprocessor/awk/sed/...

E.g. when defining dynamic -@.service systemd services you could use the dynamic variable to actually modify file content of a configuration file used in a ExecStart= statement. (Well, you could always prepend another ExecStart= command that creates the configuration file and then use the just created config file in the next line. But that wouldn't be as elegant and infeasibel in some situations.)


There's a haskell project called "dotfs" that does something like what you're describing. This may be defunct, however.

It would be easy to put something together in python using fusepy. I've attached a gist (based on fusepy-base) which does almost what you're asking, by simply running the contents of each file through a bash echo, and expanding everything accordingly. This way you can also have dynamic input from other programs, via $().


If you want to tweak it, you can just fiddle with the rewrite functions at the top to do a more specific (or safer, that might be a good idea) kind of variable expansion.

  • Thanks! I am actually working on a go implementation, using fuse and a mustache parser and go's own template parser :) – sebastian Apr 28 '16 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.