Automatic replace variables in configuration file templates from environment variables.
The parameters program takes an input file template and a given regular expression for searching environment variables. The variables in the template file will be replaced by the values of found environment variables by the exact same name.
The project outlines as described in my blog post about Open Source Software Collaboration.
- The main purpose of this software is to handle one template file and generate another file out of that.
- This list is open. Feel free to request features.
First set the environment variables. This can also come from GitLab CI variables:
export SYMF_DB_USER=my_user
export SYMF_DB_PASS=my_super_secret_passwordThen set up a dotenv template file (.env.dist):
DB_USER=@SYMF_DB_USER@
DB_PASS=@SYMF_DB_PASS@Now parameters will replace the variables:
$ parameters --input .env.dist --regexp ^SYMF_ > .envThis will take .env.dist as input file and ^SYMF_ as regular expression to search for variables in your shell environment. Searching the environment variables by a given regular expression is the same as running env | grep ^SYMF_ in your shell.
The result in .env file:
DB_USER=my_user
DB_PASS=my_super_secret_passwordYou can also use different environments like Testing, Staging, Production, etc.
$ parameters --input .env.dist --regexp ^SYMF_ --env testing > .envtesting will be converted to TESTING.
$ parameters --input .env.dist --regexp ^SYMF_ --instance shopa > .envshopa will be converted to SHOPA.
Also a combination is possible.
$ parameters --input .env.dist --regexp ^SYMF_ --env testing --instance shopa > .envRun parameters --help to see more parameters.
$ brew install boost$ sudo apt-get install --no-install-recommends libboost-filesystem-dev libboost-program-options-devYou need a modern C++ compiler that supports C++14 and CMake 3.8 or later.
This will build the binary:
$ ./bin/build.shThen the binary is available in build_release/bin.
After building the project, run:
$ ./bin/install.shOnly Debian 9 (stretch) is supported.
Add the public GPG key to the apt sources keyring:
$ wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=bintray' | sudo apt-key add -Verify key on the keyring. This should print out informations about the key:
$ apt-key list bintray@bintray.comAdd apt source file and update:
$ echo "deb https://dl.bintray.com/thefox/jar stretch main" > /etc/apt/sources.list.d/fox21at.list
$ apt-get updateInstall the package:
$ sudo apt-get install parametersNow you can run the program:
$ parameters --helpGo to the GitHub releases page and download the desired version file. Then run:
$ sudo dpkg --install parameters.deb-
Add the
thefox/brewerytap to brew.$ brew tap thefox/brewery
-
Actual installation
$ brew install parameters
- macOS 10.13 High Sierra
- macOS 10.14 Mojave
- Debian 8 (jessie)
- Debian 9 (stretch)