Erste Version des Auswahlmenüs implementiert. Es werden die notwendigen Scritte angezeigt.

This commit is contained in:
eichehome 2023-09-13 02:02:44 +02:00
parent 787f4c2d02
commit 7afc51226e

View file

@ -160,6 +160,75 @@ partitions_analyse () {
echo "${RESULT}" echo "${RESULT}"
} }
# print <analyse_result>
print () {
local ANALYSE_STRING="$1" # TYPE=([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}) TYPE=null
echo "Typ UUID Geräte-Pfad" | awk '{ printf "| %-10s| %-40s| %-20s|\n", $1, $2, $3 }'
awk 'BEGIN { for(f=1; f<= 77; f++) { if( f==1 || f==13 || f==55 || f==77) { printf "|" } else { printf "-" } } printf "\n" }'
until [[ "${ANALYSE_STRING}" == "" ]]
do
local CURRENT_RESULT=$(echo "${ANALYSE_STRING}" | awk '{ print $1 }')
local CURRENT_TYPE=$(echo "${CURRENT_RESULT}" | awk 'BEGIN { FS="=" } { print $1 }')
local CURRENT_UUID=$(echo "${CURRENT_RESULT}" | awk 'BEGIN { FS="=" } { print $2 }')
local CURRENT_PATH=$(lsblk -plo NAME /dev/disk/by-partuuid/"${CURRENT_UUID}" 2> /dev/null | tail -n +2)
local CURRENT_REST=${ANALYSE_STRING//${CURRENT_RESULT}}
CURRENT_REST=${CURRENT_REST# }
echo "${CURRENT_TYPE} ${CURRENT_UUID} ${CURRENT_PATH}" | awk '{ printf "| %-10s| %-40s| %-20s|\n" , $1, $2 , $3 }'
ANALYSE_STRING="${CURRENT_REST# }"
done
echo ""
}
# print_todo <Gerät> <analyse_result>
print_todo () {
local DEVICE="$1"
local ANALYSE_STRING="$2"
echo "Bitte Partitionen mit dem folgenden Eigenschaften anlegen:"
echo ""
echo "Typ Partiton-UUID Label Size" | awk '{ printf "| %-10s| %-40s| %-20s| %-5s|\n", $1, $2, $3, $4 }'
awk 'BEGIN { for(f=1; f<= 84; f++) { if( f==1 || f==13 || f==55 || f==77 || f==84) { printf "|" } else { printf "-" } } printf "\n" }'
until [[ "${ANALYSE_STRING}" == "" ]]
do
local CURRENT_RESULT=$(echo "${ANALYSE_STRING}" | awk '{ print $1}')
local CURRENT_TYPE=$(echo "${CURRENT_RESULT}" | awk 'BEGIN { FS="=" } { print $1 }')
local CURRENT_UUID=$(echo "${CURRENT_RESULT}" | awk 'BEGIN { FS="=" } { print $2 }')
if [[ "${CURRENT_UUID}" == "null" ]]
then
CURRENT_UUID="${GUIDS[${CURRENT_TYPE}]}"
case ${CURRENT_TYPE} in
"USR")
CURRENT_LABEL="${USR_LABEL}"
CURRENT_SIZE="${USR_SIZE}"
;;
"USRHASH")
CURRENT_LABEL="${USRHASH_LABEL}"
CURRENT_SIZE="${USRHASH_SIZE}"
;;
"ROOT")
CURRENT_LABEL="${ROOT_LABEL}"
CURRENT_SIZE="${ROOT_SIZE}"
;;
"SWAP")
CURRENT_LABEL="${SWAP_LABEL}"
CURRENT_SIZE="${SWAP_SIZE}"
;;
"ESP")
CURRENT_LABEL="${ESP_LABEL}"
CURRENT_SIZE="${ESP_SIZE}"
;;
*)
die 1 "Unbekannter Partitionstyp"
;;
esac
echo "${CURRENT_TYPE}=${CURRENT_UUID}=${CURRENT_LABEL}=${CURRENT_SIZE}" | awk 'BEGIN { FS="=" } { printf "| %-10s| %-40s| %-20s| %-5s|\n", $1, $2, $3, $4 }'
fi
local CURRENT_REST=${ANALYSE_STRING//${CURRENT_RESULT}}
ANALYSE_STRING="${CURRENT_REST# }"
done
echo ""
echo -e "z.B. mit dem Kommando:\n# gdisk -n 0:0:+<SIZE> -t 0:<UUID> -c 0:<LABEL> ${DEVICE}\nDer Typ wird zum erstellen der Partition(en) nicht benötigt, da er durch die UUID bestimmt wird."
}
# format <Gerät> # format <Gerät>
format () { format () {
local DEVICE="$1" local DEVICE="$1"
@ -186,15 +255,13 @@ format () {
ANALYSE_RESULT=$(partitions_analyse "${DEVICE}") ANALYSE_RESULT=$(partitions_analyse "${DEVICE}")
if [[ "${ANALYSE_RESULT}" =~ "null"+ ]] if [[ "${ANALYSE_RESULT}" =~ "null"+ ]]
then then
echo "if" echo "Irgendeine Partition fehlt"
echo ""
print "${ANALYSE_RESULT}"
print_todo "${DEVICE}" "${ANALYSE_RESULT}"
else else
echo "else" echo "Alle Partitionen gefunden, fahre fort mit den Script"
fi fi
#EXISTING_ESP=$(existing_partitions "${DEVICE}" "ESP")
#if [[ "${EXISTING_ESP}" == "no" ]]
#then
# create "ESP"
#fi
else else
erase "${DEVICE}" erase "${DEVICE}"
create "TABLE" "${DEVICE}" create "TABLE" "${DEVICE}"