inventory.sh: Get included directories

Not only wildcard
This commit is contained in:
Brice Waegeneire 2021-03-23 11:11:12 +01:00
parent 17d1f6069a
commit 07e2e8913e
2 changed files with 10 additions and 4 deletions

View file

@ -35,9 +35,15 @@ get_confs() {
while [ "$confs_size" -lt "$(stat -c %s "$confs")" ]; do
confs_size=$(stat -c %s "$confs")
for conf_file in $(cat "$confs"); do
# Get all Include directives
for included in $(awk '/^[[:space:]]*Include/ {print $2}' "$conf_file"); do
# In case a directory is included even tho it's not recomended
if [ -d "$included" ]; then
included=$included/*
fi
# XXX: Expand the filenames
for glob in $(awk '/^[[:space:]]*Include/ {print $2}' "$conf_file"); do
realpath --canonicalize-existing --quiet $glob >> "$confs" || true
realpath --canonicalize-existing --quiet $included \
| grep -v mods-available >> "$confs" || true
done
done
sort "$confs" | uniq > "$confs"_tmp && mv "$confs"_tmp "$confs"