read boot interface at boot

This commit is contained in:
Nico Schottelius 2019-12-14 17:14:13 +01:00
parent 3824bb6d94
commit 279f86a1f0

View file

@ -23,15 +23,11 @@ keyurl=https://code.ungleich.ch/ungleich-public/__ungleich_staff_ssh_access/raw/
debootstrap "${suite}" "${dir}"
chroot ${dir} apt install -y openssh-server rdnssd linux-image-amd64
# need non-free for firmware-bnx2
echo 'deb http://pkgmaster.devuan.org/merged ${suite} main contrib non-free' > ${dir}/etc/apt/sources.list
cat > ${dir}/etc/network/interfaces << EOF
auto lo
iface lo inet loopback
chroot ${dir} apt install -y openssh-server rdnssd linux-image-amd64 firmware-bnx2
auto eth0
iface eth0 inet6 auto
EOF
cp ${dir}/boot/vmlinuz-* ${kernel}
@ -43,6 +39,33 @@ for key in balazs dominique jinguk nico; do
curl -s ${keyurl}/${key}.pub >> ${dir}/root/.ssh/authorized_keys
done
################################################################################
# networking
# always lo
cat > ${dir}/etc/network/interfaces << EOF
auto lo
iface lo inet loopback
EOF
# find the boot interfaces at boot
cat > ${dir}/etc/rc.local <<EOF
mac=\$(cat /proc/cmdline | tr ' ' '\n' | awk -F= '/bootdev/ { print \$2 }')
dev=\$(ip -o link | awk -F: "/\$mac/ { print \\\$2 }" | sed 's/ *//g')
cat > /etc/network/interfaces.d/bootinterface << eof
auto \$dev
iface \$dev inet6 auto
eof
ifup "\${dev}"
exit 0
EOF
# ensure there is /init in the initramfs -> otherwise there is a kernel panic
# reason: initramfs is designed to be PRE regular os, so /init usually hands over to /sbin/init
# in our case, they are just the same