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.

61 lines
1.3 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 /dev/md1 as boot device
"./hardware/${1}/parted.sh" "$2"
7 years ago
# encrypt and unlock root device
echo -n 'Enter luks password: '
7 years ago
read -s md0pwd
echo #to indicate progress after password prompt
7 years ago
echo -n $md0pwd | cryptsetup -q luksFormat /dev/md0
echo -n $md0pwd | cryptsetup open --type luks /dev/md0 md0-unlocked
unset md0pwd
# format
chroot=/mnt/md0-unlocked
# root device
mkfs.btrfs /dev/mapper/md0-unlocked
7 years ago
mkdir /mnt/md0-unlocked
mount /dev/mapper/md0-unlocked /mnt/md0-unlocked
# boot device
mkfs.btrfs /dev/md1
7 years ago
mkdir "$chroot/boot"
mount /dev/md1 "$chroot/boot"
5 years ago
# esp device
mkfs.fat "hardware/${1}/esp"
mkdir "$chroot/boot/efi"
mount "hardware/${1}/esp" "$chroot/boot/efi"
7 years ago
# debootstrap
debootstrap --variant=minbase --arch=amd64 buster "$chroot" https://deb.debian.org/debian/
7 years ago
mount -t proc none "$chroot/proc"
mount -t sysfs none "$chroot/sys"
mount -o bind /dev "$chroot/dev"
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"