#!/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" echo "deb http://deb.debian.org/debian/ $release-updates main contrib non-free" >> "$chroot_dir/etc/apt/sources.list" chroot "$chroot_dir" apt-get update chroot "$chroot_dir" apt-get install -y firmware-bnx2 # SSH server, DNS updates from RAs, LVM2. chroot "$chroot_dir" apt-get install -y openssh-server rdnssd lvm2 # Network tools. chroot "$chroot_dir" apt-get install -y vlan bridge-utils # Useful things for cdist manifests to run properly and humans to be happy. chroot "$chroot_dir" apt-get install -y lsb-release ca-certificates vim locales # Install and extract kernel. chroot "$chroot_dir" apt-get install -y linux-image-amd64 cp "$chroot_dir"/boot/vmlinuz-* "$output_dir/kernel-$basename" # Deploy SSH keys. 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" # 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 post-up /sbin/ip link set \$IFACE mtu 9000 # OpenNebula VM vlan auto eth0.10 iface eth0.10 inet6 auto vlan-raw-device eth0 post-up /sbin/ip link set \$IFACE mtu 9000 # OpenNebula VM bridge auto br-vms iface br-vms inet6 auto bridge_ports eth0.10 post-up /sbin/ip link set \$IFACE mtu 9000 EOF # Build initramfs from generated installation. (cd "$chroot_dir"; find . | cpio -H newc -o | gzip -9 > "../initramfs-$basename")