ArchOS/manual-build/init.sh
2023-12-20 01:31:19 +01:00

56 lines
No EOL
1.6 KiB
Bash

#!/bin/bash
# shellcheck disable=SC2059 # $1 and $2 can contain the printf modifiers
out() { printf "$1 $2\n" "${@:3}"; }
error() { out "==> ERROR:" "$@"; } >&2
warning() { out "==> WARNING:" "$@"; } >&2
msg() { out "==>" "$@"; }
die() { error "$@"; exit 1; }
declare -A GUID=""
GUID=([ESP]="c12a7328-f81f-11d2-ba4b-00a0c93ec93b" [ROOT]="4f68bce3-e8cd-4db1-96e7-fbcaf984b709")
DEVICE="/dev/vda"
mkdir repart || die 'Fehler beim erstellen des Directory'
cd repart || die 'Fehler beim Directorywechsel'
cat >10-esp.conf <<EOF || die 'Fehler beim erstellen der Datei 10-esp.conf'
[Partition]
Type=esp
Label=EFI System Partition
SizeMinBytes=1G
SizeMaxBytes=1G
Format=vfat
EOF
cat >20-root.conf <<EOF || die 'Fehler beim erstellen der Datei 20-root.conf'
[Partition]
Type=root
Label=Root Partition
SizeMinBytes=15G
SizeMaxBytes=15G
Format=ext4
EOF
cd .. || die 'Fehler beim Directorywechsel'
[[ -b ${DEVICE} ]] || die 'Blockdevice nicht vorhanden'
systemd-repart --definitions=repart --dry-run=no --empty=allow "${DEVICE}"
UUID_ROOT=$(lsblk -lo PARTTYPE,PARTUUID "${DEVICE}" | grep -i "${GUID[ROOT]}" | awk '{ print $2 }')
UUID_ESP=$(lsblk -lo PARTTYPE,PARTUUID "${DEVICE}" | grep -i "${GUID[ESP]}" | awk '{ print $2 }')
declare -A UUID=""
UUID=( [ROOT]="${UUID_ROOT}" [ESP]="${UUID_ESP}" )
mount /dev/disk/by-partuuid/"${UUID[ROOT]}" /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-partuuid/"${UUID[ESP]}" /mnt/boot
# Pacman im Live-System konfigurieren
sed -i 's/#\(Color\)/\1/' /etc/pacman.conf
# Umbruch notwendug
sed -i 's/#\(ParallelDownloads\s=\s5\)/\1\
ILoveCandy/' /etc/pacman.conf
./archos-bootstrap /mnt systemd