Skip to content

Commit 0d66136

Browse files
krono3XX0
authored andcommitted
Allow for config drop-ins
Enhancement to /etc/enroot/enroot.conf: If the directory /etc/enroot/enroot.conf.d exisits, also load all files named *.conf in the same manner as the .conf file in asciicographical order (modulo LC_COLLATE) Signed-off-by: Tobias Pape <tobias@netshed.de>
1 parent 067079e commit 0d66136

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ UTILS := bin/enroot-aufs2ovlfs \
3838
bin/enroot-switchroot \
3939
bin/enroot-nsenter
4040

41-
CONFIG := conf/enroot.conf
41+
CONFIGFILE := enroot.conf
42+
CONFIG := conf/$(CONFIGFILE)
43+
CONFIGINFO := conf/$(CONFIGFILE).d/README
4244

4345
HOOKS := conf/hooks/10-aptfix.sh \
4446
conf/hooks/10-cgroups.sh \
@@ -125,7 +127,7 @@ depsclean:
125127

126128
install: all
127129
install -d -m 755 $(SYSCONFDIR) $(LIBDIR) $(BINDIR) $(DATADIR)
128-
install -d -m 755 $(addprefix $(SYSCONFDIR)/, environ.d mounts.d hooks.d)
130+
install -d -m 755 $(addprefix $(SYSCONFDIR)/, environ.d mounts.d hooks.d $(CONFIGFILE).d)
129131
install -d -m 755 $(addprefix $(DATADIR)/, environ.d mounts.d hooks.d)
130132
install -m 644 $(ENVIRON) $(SYSCONFDIR)/environ.d
131133
install -m 644 $(MOUNTS) $(SYSCONFDIR)/mounts.d
@@ -134,6 +136,7 @@ install: all
134136
install -m 644 $(MOUNTS_EXTRA) $(DATADIR)/mounts.d
135137
install -m 644 $(CONFIG_EXTRA) $(DATADIR)
136138
install -m 644 $(CONFIG) $(SYSCONFDIR)
139+
install -m 644 $(CONFIGINFO) $(SYSCONFDIR)/$(CONFIGFILE).d
137140
install -m 644 $(SRCS) $(LIBDIR)
138141
install -m 755 $(BIN) $(UTILS) $(DEPS) $(BINDIR)
139142

conf/enroot.conf.d/README

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Drop-ins for enroot.conf
2+
#
3+
# All files in this directory named *.conf are read in shell expansion order
4+
# (ie, asciicographical, possibly influenced by LC_COLLATE)
5+
#
6+
# Any file to be processed must adhere to the same format as enroot.conf.
7+
# See there for details.
8+
#
9+
# If necessary, a numbering scheme (10-default.conf, 20-local.conf, 30-....conf)
10+
# might be beneficial.
11+
#
12+
# EOF

doc/configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The following table describes standard paths used by the runtime:
1717
| `ENROOT_DATA_PATH` | `${XDG_DATA_HOME}/enroot` | Path to user container storage |
1818
| `ENROOT_TEMP_PATH` | `${TMPDIR}` | Path to temporary directory |
1919

20+
When `enroot.conf` has been read, and if there is a directory `enroot.conf.d` next to `enroot.conf`, all files in that directory matching `*.conf` will be considered, too.
2021

2122
## Container configuration
2223

enroot.in

+14-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ config::export() {
2828
[ -n "${3-}" ] && export "$1=$2" || export "$1=${!1:-$2}"
2929
}
3030

31-
config::init() {
31+
config::load() {
3232
local -r file="$1" overwrite="${2-}"
3333

3434
if [ -s "${file}" ] && ! "${BASH}" -n "${file}" > /dev/null 2>&1; then
@@ -47,6 +47,19 @@ config::init() {
4747
fi
4848
}
4949

50+
config::init() {
51+
local -r file="$1" overwrite="${2-}"
52+
53+
config::load "${file}" "${overwrite}"
54+
if [ -d "${file}.d" ]; then
55+
shopt -s nullglob
56+
for dropin in "${file}.d"/*".conf"; do
57+
config::load "${dropin}" "${overwrite}"
58+
done
59+
shopt -u nullglob
60+
fi
61+
}
62+
5063
config::fini() {
5164
for var in $(compgen -e "ENROOT_"); do
5265
if [[ "${!var}" =~ ^(no?|N[oO]?|[fF](alse)?|FALSE)$ ]]; then

0 commit comments

Comments
 (0)