ArchOS/build/archos-build.uefi

187 lines
4.6 KiB
Bash

#!/usr/bin/bash
#DEVICE="ArchOS.raw"
DEVICE="/dev/vda"
declare -A GUID=""
GUID=([ESP]="c12a7328-f81f-11d2-ba4b-00a0c93ec93b" [ROOT]="4f68bce3-e8cd-4db1-96e7-fbcaf984b709")
mkdir repart
cd repart || exit
cat > 10-esp.conf << EOF
[Partition]
Type=esp
Label=EFI System Partition
SizeMinBytes=512M
SizeMaxBytes=512M
Format=vfat
EOF
cat > 30-root.conf << EOF
[Partition]
Type=root
Label=ArchOS Build Root
Format=ext4
GrowFileSystem=yes
EOF
cat > 20-swap.conf << EOF
[Partition]
Type=swap
Label=ArchOS Build Swap
SizeMinBytes=512M
SizeMaxBytes=3G
Format=swap
EOF
cd .. || exit
# Temporär
#touch "${DEVICE}"
#systemd-repart --definitions=repart --dry-run=no --size=auto --empty=allow "${DEVICE}"
systemd-repart --definitions=repart --dry-run=no --empty=allow "${DEVICE}"
#systemd-repart --definitions=repart --dry-run=no --size=10G --empty=create "${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
TIMEZONE="Europe/Berlin"
LANG="de_DE.UTF-8"
KEYMAP="de-latin1"
HOSTNAME_NEW="arch-build"
KERNEL="linux"
BASE=( base )
BASE_DEVEL=( base-devel)
INITRD=( mkinitcpio )
MICROCODE="amd-ucode"
#WIFI_BACKEND=( wpa_supplicant )
NETWORK=( iptables-nft firewalld inetutils avahi )
MKOSI=( mkosi cpio gptfdisk )
OTHER=( vim "${MKOSI[@]}" git lynx openssh htop bash-completion man-db man-pages reflector "${BASE[@]}" "${BASE_DEVEL[@]}" "${INITRD[@]}" plymouth linux-firmware xdg-utils opendoas )
pacstrap /mnt "${KERNEL}" "${MICROCODE}" "${NETWORK[@]}" "${OTHER[@]}"
arch-chroot /mnt hwclock --systohc
arch-chroot /mnt rm -rf /etc/localtime
arch-chroot /mnt ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
sed -i 's/#\(Color\)/\1/' /mnt/etc/pacman.conf
# Umbruch notwendug
sed -i 's/#\(ParallelDownloads\s=\s5\)/\1\
ILoveCandy/' /mnt/etc/pacman.conf
sed -i "s/#\(${LANG}\)/\1/" /mnt/etc/locale.gen
arch-chroot /mnt locale-gen
echo "LANG=${LANG}" > /mnt/etc/locale.conf
echo "KEYMAP=${KEYMAP}" > /mnt/etc/vconsole.conf
echo "${HOSTNAME_NEW}" > /mnt/etc/hostname
cat > /mnt/etc/hosts << EOF
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
cat /mnt/etc/doas.conf << EOF
permit :wheel
EOF
arch-chroot /mnt chpasswd <<< "root:testen"
arch-chroot /mnt useradd -mG wheel build
arch-chroot /mnt chpasswd <<< "build:build"
sed -i 's/#\(CHARACTER_SET:\).*/\1utf-8/' /mnt/etc/lynx.cfg
cat > /mnt/etc/xdg/reflector/reflector.conf << EOF
--save /etc/pacman.d/mirrorlist
--country Germany
--protocol https
--latest 5
EOF
mkdir -p /mnt/etc/systemd/resolved.conf.d
cat > /mnt/etc/systemd/resolved.conf.d/disable-multicastDNS.conf << EOF
[Resolve]
MulticastDNS=no
EOF
arch-chroot /mnt systemctl enable systemd-resolved
arch-chroot /mnt systemctl enable systemd-timesyncd
#arch-chroot /mnt systemctl enable NetworkManager
arch-chroot /mnt systemctl enable systemd-networkd
arch-chroot /mnt systemctl enable reflector.timer
arch-chroot /mnt systemctl enable firewalld
arch-chroot /mnt systemctl enable fstrim.timer
#arch-chroot /mnt systemctl enable gdm
arch-chroot /mnt systemctl enable avahi-daemon
#arch-chroot /mnt systemctl enable bluetooth
sed -i 's/^HOOKS=(.*)/HOOKS=(base systemd keyboard plymouth autodetect sd-vconsole modconf kms block filesystems fsck)/' /mnt/etc/mkinitcpio.conf
arch-chroot /mnt mkinitcpio -p "${KERNEL}"
arch-chroot /mnt bootctl install
cat > /mnt/boot/loader/loader.conf << EOF
timeout 5
console-mode max
editor yes
default *
EOF
cat > /mnt/boot/loader/entries/arch.conf << EOF
title Arch Linux Build
version 0.1
linux /vmlinuz-${KERNEL}
initrd /${MICROCODE}.img
initrd /initramfs-${KERNEL}.img
options quiet splash rw
EOF
mkdir -p /mnt/usr/lib/repart.d
#cd repart || exit
cat > /mnt/usr/lib/repart.d/10-esp.conf << EOF
[Partition]
Type=esp
Label=EFI System Partition
SizeMinBytes=512M
SizeMaxBytes=512M
Format=vfat
EOF
cat > /mnt/usr/lib/repart.d/20-root.conf << EOF
[Partition]
Type=root
Label=ArchOS Build Root
Format=ext4
GrowFileSystem=yes
EOF
cat > /mnt/usr/lib/repart.d/30-swap.conf << EOF
[Partition]
Type=swap
Label=ArchOS Build Swap
SizeMinBytes=512M
SizeMaxBytes=3G
Format=swap
EOF
exit 0