Update create_lxc.sh

This commit is contained in:
CanbiZ 2025-07-01 13:32:19 +02:00
parent 7384b1f1a2
commit 1e9036acf2

View File

@ -57,7 +57,8 @@ function check_storage_support() {
local CURRENT_NAME="" CURRENT_TYPE="" CURRENT_CONTENTS=() local CURRENT_NAME="" CURRENT_TYPE="" CURRENT_CONTENTS=()
while IFS= read -r line || [[ -n "$line" ]]; do while IFS= read -r line || [[ -n "$line" ]]; do
if [[ "$line" =~ ^([a-z0-9]+):[[:space:]]*([a-zA-Z0-9_-]+) ]]; then # Match Speicher-Typ und Name
if [[ "$line" =~ ^(dir|lvm|lvmthin|zfspool):[[:space:]]*([a-zA-Z0-9._-]+) ]]; then
[[ -n "$CURRENT_NAME" ]] && { [[ -n "$CURRENT_NAME" ]] && {
if [[ " ${CURRENT_CONTENTS[*]} " =~ " $CONTENT " ]]; then if [[ " ${CURRENT_CONTENTS[*]} " =~ " $CONTENT " ]]; then
VALID_STORAGES+=("$CURRENT_NAME") VALID_STORAGES+=("$CURRENT_NAME")
@ -66,7 +67,11 @@ function check_storage_support() {
} }
CURRENT_TYPE="${BASH_REMATCH[1]}" CURRENT_TYPE="${BASH_REMATCH[1]}"
CURRENT_NAME="${BASH_REMATCH[2]}" CURRENT_NAME="${BASH_REMATCH[2]}"
elif [[ "$line" =~ ^[[:space:]]*content[[:space:]]*[=]?[[:space:]]*(.+)$ ]]; then continue
fi
# Match content-Zeile
if [[ "$line" =~ ^[[:space:]]*content[[:space:]]*=?[[:space:]]*(.+)$ ]]; then
IFS=',' read -ra PARTS <<<"${BASH_REMATCH[1]}" IFS=',' read -ra PARTS <<<"${BASH_REMATCH[1]}"
for c in "${PARTS[@]}"; do for c in "${PARTS[@]}"; do
CURRENT_CONTENTS+=("$(echo "$c" | xargs)") CURRENT_CONTENTS+=("$(echo "$c" | xargs)")
@ -74,17 +79,14 @@ function check_storage_support() {
fi fi
done </etc/pve/storage.cfg done </etc/pve/storage.cfg
# Letzten Block prüfen
if [[ -n "$CURRENT_NAME" ]]; then if [[ -n "$CURRENT_NAME" ]]; then
if [[ " ${CURRENT_CONTENTS[*]} " =~ " $CONTENT " ]]; then if [[ " ${CURRENT_CONTENTS[*]} " =~ " $CONTENT " ]]; then
VALID_STORAGES+=("$CURRENT_NAME") VALID_STORAGES+=("$CURRENT_NAME")
fi fi
fi fi
if [[ ${#VALID_STORAGES[@]} -eq 0 ]]; then [[ ${#VALID_STORAGES[@]} -gt 0 ]]
return 1
else
return 0
fi
} }
# This checks for the presence of valid Container Storage and Template Storage locations # This checks for the presence of valid Container Storage and Template Storage locations