2023-07-25 17:54:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# VARIABLEN:
|
|
|
|
DRIVE="/dev/vda"
|
|
|
|
ESP="512M"
|
|
|
|
USR="10G"
|
|
|
|
ROOT_LABEL="root"
|
|
|
|
USR_LABEL="usr"
|
|
|
|
ESP_LABEL="EFI"
|
|
|
|
|
2023-07-25 18:16:29 +00:00
|
|
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
2023-07-25 17:54:43 +00:00
|
|
|
|
|
|
|
CHECK_EXISTENCE_OUTPUT=$(lsblk -o NAME | grep -c "^${DRIVE//\/dev\/}")
|
|
|
|
|
|
|
|
if [[ ${CHECK_EXISTENCE_OUTPUT} -lt 1 ]]; then
|
|
|
|
echo "Platte existiert nicht, Abbruch!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Platte existiert , Weitermachen."
|
2023-07-25 18:16:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
RECREATE_PARTITIONS="1"
|
2023-07-25 18:54:49 +00:00
|
|
|
declare -A PARTITIONS_PRESENT=()
|
2023-07-25 18:16:29 +00:00
|
|
|
|
2023-07-25 20:14:02 +00:00
|
|
|
CHECK_PARTITIONS_OUTPUT=$(lsblk -po NAME,PARTTYPE | grep "${DRIVE}[0-9]")
|
2023-07-25 18:16:29 +00:00
|
|
|
|
|
|
|
CHECK_ESP=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "c12a7328-f81f-11d2-ba4b-00a0c93ec93b")
|
2023-07-25 18:54:49 +00:00
|
|
|
PARTITIONS_PRESENT+=([ESP]="${CHECK_ESP}")
|
2023-07-25 18:16:29 +00:00
|
|
|
|
|
|
|
CHECK_USR=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "8484680c-9521-48c6-9c11-b0720656f69e")
|
2023-07-25 18:54:49 +00:00
|
|
|
PARTITIONS_PRESENT+=([USR]="${CHECK_USR}")
|
2023-07-25 18:16:29 +00:00
|
|
|
|
|
|
|
CHECK_USRHASH=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "77ff5f63-e7b6-4633-acf4-1565b864c0e6")
|
2023-07-25 18:54:49 +00:00
|
|
|
PARTITIONS_PRESENT+=([USRHASH]="${CHECK_USRHASH}")
|
2023-07-25 18:16:29 +00:00
|
|
|
|
2023-07-25 18:47:41 +00:00
|
|
|
CHECK_ROOT=$(echo "${CHECK_PARTITIONS_OUTPUT}" | grep -c "4f68bce3-e8cd-4db1-96e7-fbcaf984b709")
|
2023-07-25 18:54:49 +00:00
|
|
|
PARTITIONS_PRESENT+=([ROOT]="${CHECK_ROOT}")
|
2023-07-25 18:16:29 +00:00
|
|
|
|
2023-07-25 18:54:49 +00:00
|
|
|
echo "ESP: ${CHECK_ESP}, USR: ${CHECK_USR}, USRHASH: ${CHECK_USRHASH}, ROOT: ${CHECK_ROOT}"
|
|
|
|
|
2023-07-25 21:25:54 +00:00
|
|
|
if [[ ${PARTITIONS_PRESENT[ROOT]} -eq 1 && ${PARTITIONS_PRESENT[USR]} -eq 1 && ${PARTITIONS_PRESENT[USRHASH]} -eq 1 && ${PARTITIONS_PRESENT[ESP]} -eq 1 ]]; then
|
|
|
|
echo "Alle Partitionen vorhanden."
|
|
|
|
elif [[ ${PARTITIONS_PRESENT[ROOT]} -eq 0 && ${PARTITIONS_PRESENT[USR]} -eq 0 && ${PARTITIONS_PRESENT[USRHASH]} -eq 0 && ${PARTITIONS_PRESENT[ESP]} -eq 0 ]]; then
|
|
|
|
echo "Keine Partition ist vorhanden."
|
|
|
|
echo "Partitionen werden erstellt."
|
2023-07-25 21:44:31 +00:00
|
|
|
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}"
|
2023-07-25 19:02:20 +00:00
|
|
|
else
|
2023-07-25 21:25:54 +00:00
|
|
|
echo " ##################################################################################"
|
|
|
|
echo " ##################################################################################"
|
|
|
|
echo " ## _______ _ _ ___________ _ _ ___ _ ______ ##"
|
|
|
|
echo " ## /\ / ______ \| | | |___ _____| | | | \ | |/ ___ \ ##"
|
|
|
|
echo " ## / \ | | \/| |_____| | | | | | | | |\ \ | | / \_| ##"
|
|
|
|
echo " ## / /\ \ | | | | | | | | | | | \ \ | | | ___ ##"
|
|
|
|
echo " ## / /__\ \ | | | _____ | | | | | | | | \ \ | | | |_ | ##"
|
|
|
|
echo " ## / ______ \| |_____/\| | | | | | \ \____/ | | \ \| | \___| | ##"
|
|
|
|
echo " ## /_/ \_\________/|_| |_| |_| \________/|_| \___|\_______| ##"
|
|
|
|
echo " ## ##"
|
|
|
|
echo " ##################################################################################"
|
|
|
|
echo " ##################################################################################"
|
|
|
|
echo ""
|
|
|
|
echo " Partitionen teilweise vorhanden."
|
|
|
|
echo " Fehlende Partitionen:"
|
|
|
|
for part in "${!PARTITIONS_PRESENT[@]}"; do
|
2023-07-25 21:30:25 +00:00
|
|
|
if [[ ${PARTITIONS_PRESENT[$part]} -eq 0 ]]; then
|
|
|
|
case $part in
|
|
|
|
"ROOT" )
|
|
|
|
echo " - Root-Partition"
|
|
|
|
;;
|
|
|
|
"USR" )
|
|
|
|
echo " - /usr-Partition"
|
|
|
|
;;
|
|
|
|
"USRHASH" )
|
|
|
|
echo " - /usr-Verity-Partition"
|
|
|
|
;;
|
|
|
|
"ESP" )
|
|
|
|
echo " - ESP-Partition"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2023-07-25 21:25:54 +00:00
|
|
|
done
|
|
|
|
echo ""
|
|
|
|
echo " =================================================================================="
|
|
|
|
echo ""
|
|
|
|
echo " Alle Partitionen werden neu erstellt!"
|
|
|
|
echo " Die gesammte Platte ${DRIVE//\/dev\/} wird verwendet!"
|
|
|
|
echo " =================================================================================="
|
|
|
|
echo ""
|
|
|
|
read -r -p " Partitionen trotz der Warnung neu erstellen? (j/N): " confirm_recreate_partitions
|
|
|
|
if [[ ${confirm_recreate_partitions} == [jJ] ]]; then
|
|
|
|
echo
|
|
|
|
echo "Recreate Partitions"
|
2023-07-25 21:44:31 +00:00
|
|
|
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}"
|
2023-07-25 21:25:54 +00:00
|
|
|
else
|
|
|
|
echo "Do nothing (Partitions)"
|
|
|
|
fi
|
2023-07-25 18:54:49 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-25 21:25:54 +00:00
|
|
|
# if [[ ${PARTITIONS_PRESENT[ROOT]} -eq 1 ]]; then
|
|
|
|
# echo "Root-Partition vorhanden."
|
|
|
|
# read -r -p "Partition trotzdem neuerstellen? (j/N): " confirm_root
|
|
|
|
# if [[ ${confirm_root} == [jJ] ]]; then
|
|
|
|
# echo "Root-Partition wird neu erstellt"
|
|
|
|
# echo sgdisk -n 0:
|
|
|
|
# else
|
|
|
|
# echo "Root-Partition wird nicht neu erstellt"
|
|
|
|
# fi
|
|
|
|
# else
|
|
|
|
# echo "Root-Partition nicht vorhanden."
|
|
|
|
# fi
|
|
|
|
|
|
|
|
# if [[ ${PARTITIONS_PRESENT[USR]} -eq 1 ]]; then
|
|
|
|
# echo "/usr-Partition vorhanden."
|
|
|
|
# read -r -p "Partition trotzdem neuerstellen? (j/N): " confirm_usr
|
|
|
|
# if [[ ${confirm_usr} == [jJ] ]]; then
|
|
|
|
# echo "/usr-Partition wird neu erstellt"
|
|
|
|
# else
|
|
|
|
# echo "/usr-Partition wird nicht neu erstellt"
|
|
|
|
# fi
|
|
|
|
# else
|
|
|
|
# echo "/usr-Partition nicht vorhanden."
|
|
|
|
# fi
|
|
|
|
|
|
|
|
# if [[ ${PARTITIONS_PRESENT[USRHASH]} -eq 1 ]]; then
|
|
|
|
# echo "/usr-Verity-Partition vorhanden."
|
|
|
|
# read -r -p "Partition trotzdem neuerstellen? (j/N): " confirm_usrhash
|
|
|
|
# if [[ ${confirm_usrhash} == [jJ] ]]; then
|
|
|
|
# echo "/usr-Verity-Partition wird neu erstellt"
|
|
|
|
# else
|
|
|
|
# echo "/usr-Verity-Partition wird nicht neu erstellt"
|
|
|
|
# fi
|
|
|
|
# else
|
|
|
|
# echo "/usr-Verity-Partition nicht vorhanden."
|
|
|
|
# fi
|
|
|
|
|
|
|
|
# if [[ ${PARTITIONS_PRESENT[ESP]} -eq 1 ]]; then
|
|
|
|
# echo "ESP-Partition vorhanden."
|
|
|
|
# read -r -p "Partition trotzdem neuerstellen? (j/N): " confirm_esp
|
|
|
|
# if [[ ${confirm_esp} == [jJ] ]]; then
|
|
|
|
# echo "ESP-Partition wird neu erstellt"
|
|
|
|
# else
|
|
|
|
# echo "ESP-Partition wird nicht neu erstellt"
|
|
|
|
# fi
|
|
|
|
# else
|
|
|
|
# echo "ESP-Partition nicht vorhanden."
|
|
|
|
# fi
|
|
|
|
# _______ _ _ ___________ _ _ ___ _ ______
|
|
|
|
# /\ / ______ \| | | |___ _____| | | | \ | |/ ___ \
|
|
|
|
# / \ | | \/| |_____| | | | | | | | |\ \ | | / \_|
|
|
|
|
# / /\ \ | | | | | | | | | | | \ \ | | | ___
|
|
|
|
# / /__\ \ | | | _____ | | | | | | | | \ \ | | | |_ |
|
|
|
|
# / ______ \| |_____/\| | | | | | \ \____/ | | \ \| | \___| |
|
|
|
|
#/_/ \_\________/|_| |_| |_| \________/|_| \___|\_______|
|