Ein dynamisches Zählen der Partitionen hinzugefügt.

This commit is contained in:
eichehome 2023-07-20 21:46:22 +02:00
parent e4fbdbe700
commit e1246c407e

View file

@ -98,12 +98,17 @@ UUID_ESP=""
UUID_ROOT="" UUID_ROOT=""
UUID_USR="" UUID_USR=""
# Anzahl der Partitionen ermitteln
DRIVE_NAME=${DRIVE//\/dev\/}
declare -i NUMBER_OF_PARTITIONS;
NUMBER_OF_PARTITIONS=$(lsblk | grep -c "${DRIVE_NAME}")
NOCASEMATCH_UNSET=$(shopt -u | grep -c nocasematch) NOCASEMATCH_UNSET=$(shopt -u | grep -c nocasematch)
if [[ $NOCASEMATCH_UNSET ]]; then if [[ $NOCASEMATCH_UNSET ]]; then
shopt -s nocasematch shopt -s nocasematch
fi fi
for i in {1..9}; do until ${NUMBER_OF_PARTITIONS}; do
OUTPUT=$(sgdisk -i "${i}" "${DRIVE}") OUTPUT=$(sgdisk -i "${i}" "${DRIVE}")
PARTITION_EXISTS=$(echo "${OUTPUT}" | grep -c "GUID") PARTITION_EXISTS=$(echo "${OUTPUT}" | grep -c "GUID")
if [[ "${PARTITION_EXISTS}" != "0" ]]; then if [[ "${PARTITION_EXISTS}" != "0" ]]; then
@ -119,6 +124,7 @@ for i in {1..9}; do
else else
echo "no partition found" echo "no partition found"
fi fi
NUMBER_OF_PARTITIONS="${NUMBER_OF_PARTITIONS}-1"
done done
if [[ $NOCASEMATCH_UNSET ]]; then if [[ $NOCASEMATCH_UNSET ]]; then