ungleich-tools/debian-devuan-netboot.sh

68 lines
1.8 KiB
Bash
Raw Normal View History

2019-12-11 14:33:24 +00:00
#!/bin/sh
# Nico Schottelius, 2019-12-09
2019-12-11 21:56:54 +00:00
# the ugly code is llnu
#this can only run in the ungleich-tools directory because of the cat magiccommand........
2019-12-11 14:33:24 +00:00
if [ $# -ne 1 ]; then
2019-12-11 21:56:54 +00:00
echo $0 suite # rootpw
2019-12-11 14:33:24 +00:00
echo suite is for instance ascii, beowulf, etc
2019-12-11 21:56:54 +00:00
# echo rootpw: set root password
2019-12-11 14:33:24 +00:00
exit 1
fi
2019-12-11 21:56:54 +00:00
#pw=$2
2019-12-11 14:33:24 +00:00
suite=$1; shift
date=$(date +%F)
dir=${suite}-${date}
kernel=${dir}-kernel
keyurl=https://code.ungleich.ch/ungleich-public/__ungleich_staff_ssh_access/raw/master/files
debootstrap "${suite}" "${dir}"
2019-12-11 21:56:54 +00:00
chroot ${dir} apt install -y openssh-server rdnssd linux-image-amd64 # ; \
# echo "root:${pw}" | chgpasswd
2019-12-11 14:33:24 +00:00
cat > ${dir}/etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet6 auto
EOF
2019-12-11 21:56:54 +00:00
#set hostname
echo "unconfigured-host" > ${dir}/etc/hostname
#add script to display eth0's ip
# the pretty but ugly code and not working
#echo 'echo $(ip -o -6 addr show | grep -E -v "lo|one" | awk '{print $1" " $2": "$4}') >> /etc/issue' > ${dir}/etc/rc.local
#the also not working
#echo '* * * * * root ip -o -6 addr show | grep -E -v "lo|one" > /etc/issue' > ${dir}/etc/cron.d/ipv6addr
#
#echo '* * * * * root ' > ${dir}/etc/cron.d/ipv6addr
cp ./magiccommand ${dir}/etc/cron.d/ipv6addr
2019-12-11 14:33:24 +00:00
mv ${dir}/boot/vmlinuz-* ${kernel}
rm ${dir}/boot/initrd*
mkdir -p ${dir}/root/.ssh
for key in balazs dominique jinguk nico; do
curl -s ${keyurl}/${key}.pub >> ${dir}/root/.ssh/authorized_keys
done
# 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
ln -s /sbin/init ${dir}/init
( cd ${dir} ; find . | cpio -H newc -o | gzip -9 > ../${dir}-initramfs )
2019-12-11 21:56:54 +00:00
# tried to clear history but doesnt work :/
# history -c