From bc6cc564524d3f78d162689ed122c87d10aab47b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:45:22 +0200 Subject: [PATCH] Update create_lxc.sh --- misc/create_lxc.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index f5b7518b..a1918743 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -27,7 +27,7 @@ trap on_terminate TERM function on_exit() { local exit_code="$?" - [[ -n "${lockfile:-}" ]] + [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" exit "$exit_code" } @@ -56,16 +56,20 @@ function check_storage_support() { local CURRENT_NAME="" CURRENT_CONTENTS=() while IFS= read -r line || [[ -n "$line" ]]; do - # Neuer Block + # Prüfen auf Storage-Typ-Zeile (dir:, lvm:, lvmthin:, zfspool:) if [[ "$line" =~ ^(dir|lvm|lvmthin|zfspool):[[:space:]]*([a-zA-Z0-9._-]+) ]]; then - # Wenn vorheriger Block gültig war, prüfen if [[ -n "$CURRENT_NAME" && "${#CURRENT_CONTENTS[@]}" -gt 0 ]]; then if [[ " ${CURRENT_CONTENTS[*]} " =~ " $CONTENT " ]]; then VALID_STORAGES+=("$CURRENT_NAME") fi fi - CURRENT_NAME="${BASH_REMATCH[2]}" - CURRENT_CONTENTS=() + + # Nur wenn der Regex gematcht hat, darf man auf BASH_REMATCH zugreifen + CURRENT_NAME="" + if [[ ${#BASH_REMATCH[@]} -ge 3 ]]; then + CURRENT_NAME="${BASH_REMATCH[2]}" + CURRENT_CONTENTS=() + fi continue fi