34 lines
1.0 KiB
Bash
Executable File
34 lines
1.0 KiB
Bash
Executable File
#! /bin/env bash
|
|
|
|
# assume that /mnt and /mnt/boot is mounted
|
|
|
|
TARGET=/mnt
|
|
DEVICE=$(findmnt -n -o SOURCE $TARGET | sed 's/\[.*//')
|
|
UUID=$(blkid -s UUID -o value ${DEVICE})
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
echo $DIR
|
|
|
|
debootstrap stable $TARGET http://deb.debian.org/debian/
|
|
|
|
genfstab -U $TARGET >>/mnt/etc/fstab
|
|
|
|
mount -t proc /proc $TARGET/proc
|
|
mount -t sysfs /sys $TARGET/sys
|
|
mount --bind /dev $TARGET/dev
|
|
mount -t devpts /dev/pts $TARGET/dev/pts
|
|
mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
|
|
|
|
echo "deb http://deb.debian.org/debian stable main non-free-firmware" >$TARGET/etc/apt/sources.list
|
|
echo "export PATH=$PATH:/sbin/" >>$TARGET/root/.bashrc
|
|
|
|
cp $DIR/chroot-commands.sh $TARGET/root/
|
|
chmod +x $TARGET/root/chroot-commands.sh
|
|
chroot $TARGET /bin/bash -l -c '/root/chroot-commands.sh'
|
|
|
|
# fix systemd-boot
|
|
for ENTRY in $TARGET/boot/loader/entries/*.conf; do
|
|
sed -i "s/root=UUID=[a-zA-Z0-9-]*/root=UUID=${UUID}/" "${ENTRY}"
|
|
done
|
|
|
|
echo "Done! Should be good to reboot now and run post-install scripts."
|