Turn the original hook into a toaster recipe.

This commit is contained in:
Cyril Brulebois 2024-07-20 07:52:53 +02:00
parent c5254d41b4
commit 9ede6bb93f

View File

@ -1,25 +1,30 @@
echo "nameserver 1.1.1.1" > /etc/resolv.conf # This recipe is sourced by the toaster, don't try to run it!
# shellcheck disable=SC2086
toast_me() {
echo "nameserver 1.1.1.1" > $MNT/etc/resolv.conf
# Install minimal tools # Install minimal tools
apt-get update chroot $MNT apt-get update
apt-get install wget sudo avahi-daemon -y chroot $MNT apt-get install -y wget sudo avahi-daemon
apt-get clean chroot $MNT apt-get clean
# Ensure we have the pi user # Ensure we have the pi user
useradd -s /bin/bash -Gsudo -m pi chroot $MNT useradd -s /bin/bash -Gsudo -m pi
usermod -aG plugdev pi chroot $MNT usermod -aG plugdev pi
echo "pi:raspberry" | chpasswd echo "pi:raspberry" | chroot $MNT chpasswd
# Disable root login on SSH # Disable root login on SSH
mkdir -p /etc/ssh/sshd_config.d/ mkdir -p $MNT/etc/ssh/sshd_config.d/
echo "PermitEmptyPasswords no" > /etc/ssh/sshd_config.d/pirogue-ssh.conf echo "PermitEmptyPasswords no" > $MNT/etc/ssh/sshd_config.d/pirogue-ssh.conf
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/pirogue-ssh.conf echo "PermitRootLogin no" >> $MNT/etc/ssh/sshd_config.d/pirogue-ssh.conf
# Force egenerate SSH host keys if exist and enable SSH # Force generate SSH host keys if they exist and enable SSH
rm -f /etc/ssh/ssh_host_* rm -f $MNT/etc/ssh/ssh_host_*
systemctl enable ssh chroot $MNT systemctl enable ssh
# Change the hostname # Change the hostname
echo "127.0.0.1 pirogue" >> /etc/hosts echo "127.0.0.1 pirogue" >> $MNT/etc/hosts
echo "127.0.0.1 pirogue.local pirogue" >> /etc/hosts echo "127.0.0.1 pirogue.local pirogue" >> $MNT/etc/hosts
echo "::1 pirogue" >> /etc/hosts echo "::1 pirogue" >> $MNT/etc/hosts
echo "::1 pirogue.local pirogue" >> /etc/hosts echo "::1 pirogue.local pirogue" >> $MNT/etc/hosts
echo "pirogue" > /etc/hostname echo "pirogue" > $MNT/etc/hostname
# Add PTS PPA # Add PTS PPA
wget -O /etc/apt/sources.list.d/pirogue.list https://pts-project.org/debian-12/pirogue.list chroot $MNT wget -O /etc/apt/sources.list.d/pirogue.list https://pts-project.org/debian-12/pirogue.list
wget -O /etc/apt/trusted.gpg.d/pirogue.asc https://pts-project.org/debian-12/Key.gpg chroot $MNT wget -O /etc/apt/trusted.gpg.d/pirogue.asc https://pts-project.org/debian-12/Key.gpg
}