You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB
Bash

7 years ago
#!/bin/bash
set -e
apt-get -y install mdadm cryptsetup debootstrap
7 years ago
# returns /dev/md0 as root device
# returns "$boot" as boot device
"./hardware/${1}/parted.sh" "$2"
root="hardware/${1}/root"
boot="hardware/${1}/boot"
esp="hardware/${1}/esp"
7 years ago
# encrypt and unlock root device
echo -n 'Enter luks password: '
read -s root_pwd
echo #to indicate progress after password prompt
echo -n $root_pwd | cryptsetup -q luksFormat "$root"
echo -n $root_pwd | cryptsetup open --type luks "$root" root-unlocked
unset root_pwd
7 years ago
# format
chroot=/mnt/root-unlocked
7 years ago
# root device
mkfs.btrfs -f /dev/mapper/root-unlocked
mkdir /mnt/root-unlocked
mount /dev/mapper/root-unlocked /mnt/root-unlocked
7 years ago
# boot device
mkfs.btrfs -f "$boot"
7 years ago
mkdir "$chroot/boot"
mount "$boot" "$chroot/boot"
7 years ago
5 years ago
# esp device
mkfs.fat "$esp"
5 years ago
mkdir "$chroot/boot/efi"
mount "$esp" "$chroot/boot/efi"
5 years ago
7 years ago
# debootstrap
debootstrap --variant=minbase --arch=amd64 bullseye "$chroot" https://deb.debian.org/debian/
7 years ago
mount -t proc none "$chroot/proc"
mount -t sysfs none "$chroot/sys"
mount --bind /dev "$chroot/dev"
mount --bind /run "$chroot/run"
7 years ago
7 years ago
7 years ago
# set hostname
echo "$2" > "$chroot/etc/hostname"
hostname "$2"
7 years ago
# create hardware-setup copy for post-debootstrap
mkdir "$chroot/hardware-setup"
cp -a * "$chroot/hardware-setup"
chroot "$chroot" /hardware-setup/post-debootstrap-installer.sh "$1"
rm -r "$chroot/hardware-setup"