Your question seems pretty unclear, and maybe this is why nobody answered you yet.
However, you may consider the below statements coming only from my personal thoughts.
About the /etc/default folder and files.
- The beauty of linux is that you may do pretty much anything you wish -> even adding some weird files in your /etc/ folder :)
- AFAIK, the
/etc/default
folder is more related to some "defaults" configurations files (and env variables) that may be used by any apps requiring it. You may consider those files like "templates" usable by any apps,services, OS directives as "last resort" when they don't have any other custom confs available.
- Most files in
/etc/default
(in an ubuntu setup), currently have the permissions root:root -rw-r--r--
, meaning that everybody is able to read them (so there shall not be any serious "secrets" in those files), but only "root" has the right to modify them (proof that those templates are safe to use).
- On my (ubuntu setup), the
/etc/default
shows some 'openvpn' and 'google chrome` related files. -> So it is NOT ONLY reserved to OS tasks.
- For example, the
/etc/default/useradd
file defines some "Default values for useradd(8)", which may be (of course) overriden using some parameters from the useradd
commandline (or some other conf files), but it is also smart enough to look for some default missing ones by looking into the related /etc/default file when necessary.
So basically, if you want to create a tool/app/software in linux, feel free to add a default template (configuration files and/or variables) in /etc/default/anyname
, and then loading such variables into your shell script (if it is not specified by an input parameters) using the source
directive (below just a dummy example):
#!/bin/bash
source /etc/default/anyname #"anyname" file having a DEF_VAR="radigris" in it.
any_var=""
if [ -z "$1" ]; then
echo "param is unset, lets use the one from the template"
any_var="${DEF_VAR}"
else
echo "lets use the given parameter value"
any_var="$1"
fi
echo "the final parameter value is: $any_var"
You also mentioned compatibility with containers
About containers compatibility, assuming you are talking about docker
containers: I also do not see any problems or issues with it...
Lets assume you want to make an /etc/default/anyname
available inside a docker container you may probably use this:
docker run -v /etc/default/anyname:/CONTAINER/PATH:ro -it anycontainer
- or this
docker run -v /etc/default/anyname:/etc/default/anyname:ro -it anycontainer
(interesting: the 'ro' directive specifiable to keep the immutability aspect of the anyname file inside the container.
/etc
wouldn’t be available in containers? Are you aware of the/etc
description in the FHS? If configuration shouldn’t go in/etc
, where would you consider it appropriate to place it?