GUID durch Konstante umgeschrieben.

This commit is contained in:
eichehome 2023-07-26 02:19:33 +02:00
parent 0f1ff21489
commit f3c9aaaefc

View file

@ -1,6 +1,10 @@
#!/bin/bash
# VARIABLEN:
# Konstanten:
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")
# Variablen:
DRIVE="/dev/vda"
ESP="512M"
USR="10G"
@ -29,16 +33,16 @@ declare -A PARTITIONS_PRESENT=()
CHECK_PARTITIONS_OUTPUT=$(lsblk -plo NAME,PARTTYPE | grep -i "${DRIVE}[0-9]")
CHECK_ESP=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "c12a7328-f81f-11d2-ba4b-00a0c93ec93b")
CHECK_ESP=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "${GUID[ESP]}")
PARTITIONS_PRESENT+=([ESP]="${CHECK_ESP}")
CHECK_USR=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "8484680c-9521-48c6-9c11-b0720656f69e")
CHECK_USR=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "${GUID[USR]}")
PARTITIONS_PRESENT+=([USR]="${CHECK_USR}")
CHECK_USRHASH=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "77ff5f63-e7b6-4633-acf4-1565b864c0e6")
CHECK_USRHASH=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "${GUID[USRHASH]}")
PARTITIONS_PRESENT+=([USRHASH]="${CHECK_USRHASH}")
CHECK_ROOT=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "4f68bce3-e8cd-4db1-96e7-fbcaf984b709")
CHECK_ROOT=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "${GUID[ROOT]}")
PARTITIONS_PRESENT+=([ROOT]="${CHECK_ROOT}")
echo "ESP: ${CHECK_ESP}, USR: ${CHECK_USR}, USRHASH: ${CHECK_USRHASH}, ROOT: ${CHECK_ROOT}"
@ -49,10 +53,10 @@ elif [[ ${PARTITIONS_PRESENT[ROOT]} -eq 0 && ${PARTITIONS_PRESENT[USR]} -eq 0 &&
echo "Keine Partition ist vorhanden."
echo "Partitionen werden erstellt."
echo sgdisk -og "${DRIVE}"
echo sgdisk -n 0:0:"+${ESP}" -t "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" -c 0:"EFI System Partition" "${DRIVE}"
echo sgdisk -n 0:0:"+${USR}" -t 0:8484680c-9521-48c6-9c11-b0720656f69e -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:+512M -t 0:77ff5f63-e7b6-4633-acf4-1565b864c0e6 -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:0 -t 0:4f68bce3-e8cd-4db1-96e7-fbcaf984b709 -c 0:"ArchOS Root" "${DRIVE}"
echo sgdisk -n 0:0:"+${ESP}" -t 0:"${GUID[ESP]}" -c 0:"EFI System Partition" "${DRIVE}"
echo sgdisk -n 0:0:"+${USR}" -t 0:"${GUID[USR]}" -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:+512M -t 0:"${GUID[USRHASH]}" -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:0 -t 0:"${GUID[ROOT]}" -c 0:"ArchOS Root" "${DRIVE}"
else
echo " ##################################################################################"
echo " ##################################################################################"
@ -99,12 +103,32 @@ else
echo
echo "Recreate Partitions"
echo sgdisk -og "${DRIVE}"
echo sgdisk -n 0:0:"+${ESP}" -t "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" -c 0:"EFI System Partition" "${DRIVE}"
echo sgdisk -n 0:0:"+${USR}" -t 0:8484680c-9521-48c6-9c11-b0720656f69e -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:+512M -t 0:77ff5f63-e7b6-4633-acf4-1565b864c0e6 -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:0 -t 0:4f68bce3-e8cd-4db1-96e7-fbcaf984b709 -c 0:"ArchOS Root" "${DRIVE}"
echo sgdisk -n 0:0:"+${ESP}" -t 0:"${GUID[ESP]}" -c 0:"EFI System Partition" "${DRIVE}"
echo sgdisk -n 0:0:"+${USR}" -t 0:"${GUID[USR]}" -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:+512M -t 0:"${GUID[USRHASH]}" -c 0:"ArchOS_0.1" "${DRIVE}"
echo sgdisk -n 0:0:0 -t 0:"${GUID[ROOT]}" -c 0:"ArchOS Root" "${DRIVE}"
else
echo "Do nothing (Partitions)"
echo "Bitte die fehlenden Partitionen erstellen, um das Script zu benutzen"
for part in "${!PARTITIONS_PRESENT[@]}"; do
if [[ ${PARTITIONS_PRESENT[$part]} -eq 0 ]]; then
case $part in
"ROOT" )
echo " - Root-Partition GUID code: c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
;;
"USR" )
echo " - /usr-Partition GUID code: 8484680c-9521-48c6-9c11-b0720656f69e"
;;
"USRHASH" )
echo " - /usr-Verity-Partition GUID code: 77ff5f63-e7b6-4633-acf4-1565b864c0e6"
;;
"ESP" )
echo " - ESP-Partition GUID code: c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
;;
esac
fi
done
exit 1
fi
fi
@ -129,16 +153,17 @@ declare -A INFO_USR=""
declare -A INFO_USRHASH=""
declare -A INFO_ROOT=""
CHECK_FS_ESP=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" | grep -i "vfat" | grep -ic "fast32")
CHECK_FS_ESP=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "${GUID[ESP]}" | grep -i "vfat" | grep -ic "fast32")
CHECK_FS_USR=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "8484680c-9521-48c6-9c11-b0720656f69e" | grep -ic "ext4")
CHECK_FS_USR=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "${GUID[USR]}" | grep -ic "ext4")
CHECK_FS_USRHASH=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "77ff5f63-e7b6-4633-acf4-1565b864c0e6" | grep -ic "dm_verity_hash")
CHECK_FS_USRHASH=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "${GUID[USRHASH]}" | grep -ic "dm_verity_hash")
CHECK_FS_ROOT=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" | grep -i "ext4")
CHECK_FS_ROOT=$(echo "${CHECK_FS_EXISTENCE_OUTPUT}" | grep -i "${GUID[ROOT]}" | grep -ic "ext4")
if [[ ${CHECK_FS_ESP} -eq 0 ]]; then
echo "ESP-Dateisystem existiert nicht."
echo mkfs.vfat -F 32 -n EFI /dev/disk/
else
echo "ESP-Dateisystem existiert."
fi