Erste Teile für das Auswahlmenü fertig gestellt.
This commit is contained in:
parent
240e181576
commit
aa18bc5e73
1 changed files with 64 additions and 49 deletions
113
script.uefi
113
script.uefi
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
### Konstanten ###
|
### Konstanten ###
|
||||||
|
|
||||||
RED=$()
|
declare -A GUIDS=""
|
||||||
|
GUIDS=([ESP]="c12a7328-f81f-11d2-ba4b-00a0c93ec93b" [USR]="8484680c-9521-48c6-9c11-b0720656f69e" [USRHASH]="77ff5f63-e7b6-4633-acf4-1565b864c0e6" [ROOT]="4f68bce3-e8cd-4db1-96e7-fbcaf984b709" [SWAP]="0657fd6d-a4ab-43c4-84e5-0933c84b4f4f")
|
||||||
|
|
||||||
### DEFAULTS ###
|
### DEFAULTS ###
|
||||||
|
|
||||||
|
@ -63,9 +64,11 @@ erase () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# create <Type>
|
# create <Type> <Gerät>
|
||||||
create () {
|
create () {
|
||||||
case $1 in
|
local TYPE="$1"
|
||||||
|
local DEVICE="$2"
|
||||||
|
case ${TYPE} in
|
||||||
"USR")
|
"USR")
|
||||||
echo "sgdisk -n 0:0:+${USR_SIZE} -t 0:${GUIDS[USR]} -c 0:${USR_LABEL} ${DEVICE}"
|
echo "sgdisk -n 0:0:+${USR_SIZE} -t 0:${GUIDS[USR]} -c 0:${USR_LABEL} ${DEVICE}"
|
||||||
#sgdisk -n 0:0:+"${USR_SIZE}" -t 0:"${GUIDS[USR]}" -c 0:"${USR_LABEL}" "${DEVICE}"
|
#sgdisk -n 0:0:+"${USR_SIZE}" -t 0:"${GUIDS[USR]}" -c 0:"${USR_LABEL}" "${DEVICE}"
|
||||||
|
@ -100,10 +103,8 @@ create () {
|
||||||
existing_partitions () {
|
existing_partitions () {
|
||||||
local DEVICE="$1"
|
local DEVICE="$1"
|
||||||
local TYPE="$2"
|
local TYPE="$2"
|
||||||
echo "1: $1,2: $2" >> temp.log
|
|
||||||
if [[ $# -eq 1 ]] # Genereller test auf Partitionen
|
if [[ $# -eq 1 ]] # Genereller test auf Partitionen
|
||||||
then
|
then
|
||||||
echo "Path 1" >> temp.log
|
|
||||||
ANZAHL_PARTITIONEN_VORHANDEN=$(lsblk -pl "${DEVICE}" | grep -ic "${DEVICE}[0-9]")
|
ANZAHL_PARTITIONEN_VORHANDEN=$(lsblk -pl "${DEVICE}" | grep -ic "${DEVICE}[0-9]")
|
||||||
if [[ ${ANZAHL_PARTITIONEN_VORHANDEN} != 0 ]]
|
if [[ ${ANZAHL_PARTITIONEN_VORHANDEN} != 0 ]]
|
||||||
then
|
then
|
||||||
|
@ -113,28 +114,8 @@ existing_partitions () {
|
||||||
fi
|
fi
|
||||||
elif [[ $# -eq 2 ]] # Test auf eine bestimmte Partition
|
elif [[ $# -eq 2 ]] # Test auf eine bestimmte Partition
|
||||||
then
|
then
|
||||||
echo "Path 2" >> temp.log
|
local PARTUUID="${GUIDS[${TYPE}]}" # Hier ist ein Problem
|
||||||
case ${TYPE} in
|
echo "PARTUUID: ${PARTUUID}" >> temp.log
|
||||||
"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
|
|
||||||
echo "UUID: ${PARTUUID}" >> temp.log
|
|
||||||
SPEZIFISCHE_PARTITION_VORHANDEN=$(lsblk -o PARTTYPE "${DEVICE}" | grep -ic "${PARTUUID}")
|
SPEZIFISCHE_PARTITION_VORHANDEN=$(lsblk -o PARTTYPE "${DEVICE}" | grep -ic "${PARTUUID}")
|
||||||
if [[ "${SPEZIFISCHE_PARTITION_VORHANDEN}" == 1 ]]
|
if [[ "${SPEZIFISCHE_PARTITION_VORHANDEN}" == 1 ]]
|
||||||
then
|
then
|
||||||
|
@ -147,8 +128,41 @@ existing_partitions () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# format
|
# find_uuid_for_partition <Gerät> <Type>
|
||||||
|
find_uuid_for_partition () {
|
||||||
|
local DEVICE="$1"
|
||||||
|
local TYPE="$2"
|
||||||
|
if [[ "$(existing_partitions "${DEVICE}" "${TYPE}")" == "yes" ]]
|
||||||
|
then
|
||||||
|
uuid=$()
|
||||||
|
echo "uuid"
|
||||||
|
else
|
||||||
|
echo "null"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# partitions_analyse <Gerät>
|
||||||
|
partitions_analyse () {
|
||||||
|
local DEVICE="$1"
|
||||||
|
local RESULT=""
|
||||||
|
declare -i index=""
|
||||||
|
index=0
|
||||||
|
for type in "${!GUIDS[@]}"
|
||||||
|
do
|
||||||
|
index+=1
|
||||||
|
uuid=$(find_uuid_for_partition "${DEVICE}" "${type}")
|
||||||
|
RESULT+="${type}=${uuid}"
|
||||||
|
if [[ "$index" != "${#GUIDS[@]}" ]]
|
||||||
|
then
|
||||||
|
RESULT+=" "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "${RESULT}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# format <Gerät>
|
||||||
format () {
|
format () {
|
||||||
|
local DEVICE="$1"
|
||||||
if [[ "${FORCE}" == "yes" ]]
|
if [[ "${FORCE}" == "yes" ]]
|
||||||
then
|
then
|
||||||
erase "${DEVICE}"
|
erase "${DEVICE}"
|
||||||
|
@ -157,31 +171,33 @@ format () {
|
||||||
EXISTING_PARTITIONS=$(existing_partitions "${DEVICE}")
|
EXISTING_PARTITIONS=$(existing_partitions "${DEVICE}")
|
||||||
if [[ "${EXISTING_PARTITIONS}" == "no" ]]
|
if [[ "${EXISTING_PARTITIONS}" == "no" ]]
|
||||||
then
|
then
|
||||||
create "TABLE"
|
create "TABLE" "${DEVICE}"
|
||||||
create "ESP"
|
create "ESP" "${DEVICE}"
|
||||||
create "USR"
|
create "USR" "${DEVICE}"
|
||||||
create "ROOT"
|
create "ROOT" "${DEVICE}"
|
||||||
create "USRHASH"
|
create "USRHASH" "${DEVICE}"
|
||||||
create "SWAP"
|
create "SWAP" "${DEVICE}"
|
||||||
else
|
else
|
||||||
read -r -p "Partitionen überschreiben? [N/y]: " ask_overwrite
|
read -r -p "Partitionen überschreiben? [N/y]: " ask_overwrite
|
||||||
ask_overwrite=${ask_overwrite:="n"}
|
ask_overwrite=${ask_overwrite:="n"}
|
||||||
if [[ ${ask_overwrite} == [Nn] ]]
|
if [[ ${ask_overwrite} == [Nn] ]]
|
||||||
then
|
then
|
||||||
die 10 "Noch nicht implementiert"
|
#die 10 "Noch nicht implementiert"
|
||||||
EXISTING_ESP=$(existing_partitions "${DEVICE}" "ESP")
|
temp=$(partitions_analyse "${DEVICE}")
|
||||||
if [[ "${EXISTING_ESP}" == "no" ]]
|
echo "${temp}"
|
||||||
then
|
#EXISTING_ESP=$(existing_partitions "${DEVICE}" "ESP")
|
||||||
create "ESP"
|
#if [[ "${EXISTING_ESP}" == "no" ]]
|
||||||
fi
|
#then
|
||||||
|
# create "ESP"
|
||||||
|
#fi
|
||||||
else
|
else
|
||||||
erase "${DEVICE}"
|
erase "${DEVICE}"
|
||||||
create "TABLE"
|
create "TABLE" "${DEVICE}"
|
||||||
create "ESP"
|
create "ESP" "${DEVICE}"
|
||||||
create "USR"
|
create "USR" "${DEVICE}"
|
||||||
create "ROOT"
|
create "ROOT" "${DEVICE}"
|
||||||
create "USRHASH"
|
create "USRHASH" "${DEVICE}"
|
||||||
create "SWAP"
|
create "SWAP" "${DEVICE}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -242,8 +258,7 @@ USRHASH_LABEL="${NAME}_${VERSION}"
|
||||||
|
|
||||||
#--------------------------------------#
|
#--------------------------------------#
|
||||||
|
|
||||||
declare -A GUIDS=""
|
|
||||||
GUIDS=([ESP]="c12a7328-f81f-11d2-ba4b-00a0c93ec93b" [USR]="8484680c-9521-48c6-9c11-b0720656f69e" [USRHASH]="77ff5f63-e7b6-4633-acf4-1565b864c0e6" [ROOT]="4f68bce3-e8cd-4db1-96e7-fbcaf984b709" [SWAP]="0657fd6d-a4ab-43c4-84e5-0933c84b4f4f")
|
|
||||||
|
|
||||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
|
||||||
|
@ -282,4 +297,4 @@ fi
|
||||||
# Prüfen, ob das Script mit Root-Rechten ausgeführt wird
|
# Prüfen, ob das Script mit Root-Rechten ausgeführt wird
|
||||||
#(( EUID == 0)) || die 3 "Dieses Script muss mit Root-Privilegien aufgerufen werden"
|
#(( EUID == 0)) || die 3 "Dieses Script muss mit Root-Privilegien aufgerufen werden"
|
||||||
|
|
||||||
format
|
format "${DEVICE}"
|
Loading…
Reference in a new issue