From 05f4b13e8e9b40879bb568395587195c671021d7 Mon Sep 17 00:00:00 2001 From: eichehome Date: Mon, 11 Sep 2023 14:38:33 +0200 Subject: [PATCH] Funktion zur Erkennung von Partitionen implementiert --- script.uefi | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/script.uefi b/script.uefi index 8cbbf81..b06ced9 100755 --- a/script.uefi +++ b/script.uefi @@ -100,12 +100,42 @@ create () { existing_partitions () { if [[ $# -eq 1 ]] # Genereller test auf Partitionen then - echo "yes" # Partitionen vorhanden - #echo "no" # Partitionen nicht vorhanden + ANZAHL_PARTITIONEN_VORHANDEN=$(lsblk -pl "${DEVICE}" | grep -ic "${1}") + if [[ ${ANZAHL_PARTITIONEN_VORHANDEN} != 0 ]] + then + echo "yes" # Partitionen vorhanden + else + echo "no" # Partitionen nicht vorhanden + fi elif [[ $# -eq 2 ]] # Test auf eine bestimmte Partition then - #echo "yes" # bestimmte Partition vorhanden - echo "no" # bestimmte Partition nicht vorhanden + case $2 in + "ESP") + PARTUUID="${GUIDS[ESP]}" + ;; + "ROOT") + PARTUUID="${GUIDS[ROOT]}" + ;; + "USR") + PARTUUID="${GUIDS[USR]}" + ;; + "USRHASH") + PARTUUID="${GUIDS[USRHASH]}" + ;; + "SWAP") + PARTUUID="${GUIDS[SWAP]}" + ;; + *) + die 1 "Unbekannter Partitionstype" + ;; + esac + SPEZIFISCHE_PARTITION_VORHANDEN=$(lsblk -o PARTTYPE "${DEVICE}" | grep "${PARTUUID}") + if [[ "${SPEZIFISCHE_PARTITION_VORHANDEN}" == 1 ]] + then + echo "yes" # bestimmte Partition vorhanden + else + echo "no" # bestimmte Partition nicht vorhanden + fi else die 1 "Kein Gerät zur Prüfung auf Partitionen angegeben" fi