2020-10-04 19:52:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: debian-build-netboot.sh DEBIAN_RELEASE"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
output_dir=debian-netboot
|
|
|
|
release=$1
|
|
|
|
date=$(date +%F)
|
|
|
|
basename="$release-$date"
|
|
|
|
chroot_dir="$output_dir/$basename"
|
|
|
|
|
|
|
|
# Cleanup output directory.
|
|
|
|
rm -rf $output_dir
|
|
|
|
mkdir -p "$chroot_dir"
|
|
|
|
|
|
|
|
# Install base system.
|
|
|
|
debootstrap "$release" "$chroot_dir"
|
|
|
|
echo "unconfigured-host" > "$chroot_dir/etc/hostname"
|
|
|
|
|
|
|
|
# Add non-free repository for firmware-bnx2 network card firmware.
|
|
|
|
echo "deb http://deb.debian.org/debian/ $release main contrib non-free" > "$chroot_dir/etc/apt/sources.list"
|
2020-11-24 09:41:04 +01:00
|
|
|
echo "deb http://deb.debian.org/debian/ $release-updates main contrib non-free" >> "$chroot_dir/etc/apt/sources.list"
|
|
|
|
|
2020-10-04 19:52:58 +02:00
|
|
|
chroot "$chroot_dir" apt-get update
|
|
|
|
chroot "$chroot_dir" apt-get install -y firmware-bnx2
|
|
|
|
|
2020-10-09 14:26:47 +02:00
|
|
|
# SSH server, DNS updates from RAs, LVM2.
|
|
|
|
chroot "$chroot_dir" apt-get install -y openssh-server rdnssd lvm2
|
|
|
|
|
2020-10-11 14:47:32 +02:00
|
|
|
# Network tools.
|
|
|
|
chroot "$chroot_dir" apt-get install -y vlan bridge-utils
|
|
|
|
|
2020-10-11 14:47:32 +02:00
|
|
|
# Useful things for cdist manifests to run properly and humans to be happy.
|
2020-10-11 14:47:32 +02:00
|
|
|
chroot "$chroot_dir" apt-get install -y lsb-release ca-certificates vim locales
|
2020-10-04 19:52:58 +02:00
|
|
|
|
|
|
|
# Install and extract kernel.
|
|
|
|
chroot "$chroot_dir" apt-get install -y linux-image-amd64
|
|
|
|
cp "$chroot_dir"/boot/vmlinuz-* "$output_dir/kernel-$basename"
|
|
|
|
|
2020-10-11 14:47:32 +02:00
|
|
|
# Deploy SSH keys.
|
2020-10-04 19:52:58 +02:00
|
|
|
mkdir -p "$chroot_dir/root/.ssh"
|
|
|
|
for user in tfloure; do
|
|
|
|
curl "https://meta.recycled.cloud/~$user.keys" >> "$chroot_dir/root/.ssh/authorized_keys"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make sure there is /init in the initramfs to avoid kernel panic.
|
|
|
|
# initramfs is designed to be PRE regular os, so /init usually hands over to
|
|
|
|
# /sbin/init... which are the same in our case.
|
|
|
|
ln -fs /sbin/init "$chroot_dir/init"
|
|
|
|
|
|
|
|
# Display IP addresses on login screen.
|
|
|
|
echo '* * * * * root ip -6 -o addr show | grep -E -v " lo " > /etc/issue' > "$chroot_dir/etc/cron.d/ipv6addr"
|
|
|
|
|
2020-10-09 14:26:47 +02:00
|
|
|
# Configure networking.
|
|
|
|
cat << EOF > "$chroot_dir/etc/network/interfaces"
|
|
|
|
auto lo
|
|
|
|
iface lo inet loopback
|
|
|
|
|
|
|
|
auto eth0
|
|
|
|
allow-hotplug eth0
|
|
|
|
iface eth0 inet dhcp
|
|
|
|
iface eth0 inet6 auto
|
2020-11-24 09:41:04 +01:00
|
|
|
post-up /sbin/ip link set \$IFACE mtu 9000
|
2020-10-11 14:47:32 +02:00
|
|
|
|
|
|
|
# OpenNebula VM vlan
|
|
|
|
auto eth0.10
|
|
|
|
iface eth0.10 inet6 auto
|
|
|
|
vlan-raw-device eth0
|
2020-11-24 09:41:04 +01:00
|
|
|
post-up /sbin/ip link set \$IFACE mtu 9000
|
2020-10-11 14:47:32 +02:00
|
|
|
|
|
|
|
# OpenNebula VM bridge
|
|
|
|
auto br-vms
|
|
|
|
iface br-vms inet6 auto
|
|
|
|
bridge_ports eth0.10
|
2020-11-24 09:41:04 +01:00
|
|
|
post-up /sbin/ip link set \$IFACE mtu 9000
|
2020-10-09 14:26:47 +02:00
|
|
|
EOF
|
|
|
|
|
2020-10-04 19:52:58 +02:00
|
|
|
# Build initramfs from generated installation.
|
|
|
|
(cd "$chroot_dir"; find . | cpio -H newc -o | gzip -9 > "../initramfs-$basename")
|