server-scripts/entry.sh
2020-01-29 21:26:14 +01:00

61 lines
1 KiB
Bash
Executable file

#!/bin/bash
function first_stage(){
set -e
echo foo first_stage
apt install -y debootstrap cryptsetup btrfs-progs
echo -n luks_password:
read -s luks_password
lsblk -ftpo NAME,FSTYPE,LABEL,UUID,FSAVAIL,MOUNTPOINT
select DEVICE in $(lsblk -frpno NAME); do
echo using $DEVICE
break
done
wipefs -a ${DEVICE}
(
echo o
echo n
echo p
echo 1
echo
echo +2G
echo n
echo p
echo 2
echo
echo
echo w
) | fdisk ${DEVICE}
lsblk
echo mkfs.ext4 ${DEVICE}1
mkfs.ext4 ${DEVICE}1
(
echo $luks_password
echo $luks_password
)| cryptsetup luksFormat ${DEVICE}2
echo $luks_password | cryptsetup luksOpen ${DEVICE}2 cryptlvm
mkfs.ext4 ${DEVICE}2
mount ${DEVICE}2 $TARGET
echo mount ${DEVICE}2 $TARGET
echo debootstrap sid $TARGET
debootstrap sid $TARGET
mount ${DEVICE}1 $TARGET/boot
echo mount ${DEVICE}1 $TARGET/boot
}
function second_stage(){
set -e
echo bar second_stage
passwd
echo -n > /etc/motd
apt install -y linux-image-amd64 grub2 cryptsetup btrfs-progs locales tzdata keyboard-configuration console-common
}