From e84d58ef9fc476e1282fc38fa594eff58feb1256 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Jun 2024 09:44:48 +0200 Subject: [config-tgz] support multiple local configs Just like MiniLinux stage31 did. --- modules.d/conf-tgz/hooks/unpack-config-tgz.sh | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules.d/conf-tgz/hooks/unpack-config-tgz.sh b/modules.d/conf-tgz/hooks/unpack-config-tgz.sh index 2132423c..99ace4b4 100755 --- a/modules.d/conf-tgz/hooks/unpack-config-tgz.sh +++ b/modules.d/conf-tgz/hooks/unpack-config-tgz.sh @@ -4,15 +4,14 @@ type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # tarcopy -tarcopy() { +tarcopy() ( [ -d "$1" -a -d "$2" ] || return 1 - cd "$1" + cd "$1" || return 1 local filelist="$(mktemp)" find . \! -type d > "$filelist" tar -c -p -T "$filelist" | tar -xp -C "$2" rm -f -- "$filelist" - cd - &>/dev/null -} +) unpack_config_tgz() { local config_tgz="/etc/config.tgz" @@ -34,16 +33,19 @@ unpack_config_tgz() { warn "Failed to extract '$config_tgz' to '$extract_dir'." return 1 fi - # check SLX_LOCAL_CONFIGURATION + # check SLX_LOCAL_CONFIG source "/etc/openslx" - if [ -n "$SLX_LOCAL_CONFIGURATION" ]; then - if [ ! -d "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]; then - warn "Ignoring missing SLX_LOCAL_CONFIGURATION in '$config_tgz'." - else - tarcopy \ - "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" \ - "${extract_dir}" - fi + if [ -n "$SLX_LOCAL_CONFIG" ]; then + local mod + for mod in $SLX_LOCAL_CONFIG; do + if [ ! -d "${extract_dir}/openslx-configs/${mod}" ]; then + warn "Ignoring missing mod '$mod' in config.tgz" + else + tarcopy \ + "${extract_dir}/openslx-configs/${mod}" \ + "${extract_dir}" + fi + done fi # always purge openslx-configs/ rm -rf "${extract_dir}/openslx-configs" -- cgit v1.2.3-55-g7522