Skip to content

oskude/varifs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VariFS

VariFS is an userspace variable resolving file system, that mounts over a directory and resolves user defined «variable»s during file read.

Sorry, the code looks horrible, i just wanted this thing quick :P

Example

First we have some variables:

$ cat .varifs
foo = bar
color = #ff8800
timezone = Europe/Berlin

And some optional "secret" variables (so we can omit this from VCS):

$ cat .varifs.secret
password = secret

Then we can reference those variables in file content:

$ cat testfile
hello «foo»
what = «color|start:1»
ever = «color|hex2rgb»
pass = «password»

And in symlink target:

$ file testlink
testlink: broken symbolic link to /usr/share/zoneinfo/«timezone»

Now when we mount over that directory:

$ mkdir -p "/tmp/varifstest"
$ ../varifs "/tmp/varifstest" -o root="$PWD"

Those variables are resolved during file read:

$ cat "/tmp/varifstest/testfile"
hello bar
what = ff8800
ever = 255,136,0
pass = secret
$ file "/tmp/varifstest/testlink"
/tmp/varifstest/testlink: symbolic link to /usr/share/zoneinfo/Europe/Berlin

When done, just unmount:

$ fusermount -u "/tmp/varifstest"

Dependencies

Usage

$ varifs <WHERE_TO_MOUNT> -o root=<WHAT_TO_MOUNT>
$ fusermount -u <WHERE_TO_MOUNT>

Environment variables

Variable Information
VARIFS_VARIFILE Variable filename, default: ".varifs"
VARIFS_SECRETFILE Secret variable filename, default: ".varifs.secret"
VARIFS_PREFIX Variable reference prefix, default: "«"
VARIFS_SUFFIX Variabel reference suffix, default: "»"
VARIFS_MODSEP Variable modification separator, default: "|"
VARIFS_MODARGSEP Variable modification argument separator, default ":"

Variable mods

We can modify variable values when referecing them, the syntax is:

«variable|mod:args»
Mod Arg(s) Info
start number Remove number chars from start
mul number Multiply by number
add number Add number
hex2rgb - Convert hexadecimal color to RGB bytes

Ideas

Licence

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published