Update install script for including keyfile

This commit is contained in:
Nico Schottelius 2021-08-19 15:44:59 +02:00
parent 93832b5a90
commit 4787bb200c

View file

@ -4,17 +4,18 @@
set -e set -e
set -x set -x
if [ $# -ne 2 ]; then if [ $# -ne 3 ]; then
echo $0 suite disk echo $0 suite keyfile disk
echo suite: beowulf or similar
echo keyfile: file containing the ssh keys
echo disk: the block device
exit 1 exit 1
fi fi
suite=$1; shift suite=$1; shift
keyfile=$1; shift
disk=$1; shift disk=$1; shift
keyurl=https://key.wf
case $disk in case $disk in
/dev/sd*) /dev/sd*)
partition=${disk}1 partition=${disk}1
@ -39,15 +40,17 @@ date=$(date +%F)
dd if=/dev/zero of=${disk} bs=1M count=2 dd if=/dev/zero of=${disk} bs=1M count=2
# Partition disk with 1 Linux partition # Partition disk with 1 Linux partition
sudo sfdisk "$DISK" <<EOF sudo sfdisk "$disk" <<EOF
label: dos label: dos
,,L ,,L
EOF EOF
# For creation, if an existing filesystem is on the partitions partprobe "${disk}"
sudo mkfs.ext4 -F ${partition}
sudo mount ${partition} ${chroot_dir} # For creation, if an existing filesystem is on the partitions
mkfs.ext4 -F ${partition}
mount ${partition} ${chroot_dir}
# Devuan: debootstrap beowulf /tmp/tmp.teGuJxytz0 http://packages.devuan.org/devuan # Devuan: debootstrap beowulf /tmp/tmp.teGuJxytz0 http://packages.devuan.org/devuan
debootstrap "${suite}" "${chroot_dir}" debootstrap "${suite}" "${chroot_dir}"
@ -56,22 +59,18 @@ debootstrap "${suite}" "${chroot_dir}"
echo "deb http://pkgmaster.devuan.org/merged ${suite} main contrib non-free" > ${chroot_dir}/etc/apt/sources.list echo "deb http://pkgmaster.devuan.org/merged ${suite} main contrib non-free" > ${chroot_dir}/etc/apt/sources.list
chroot ${chroot_dir} apt update chroot ${chroot_dir} apt update
chroot ${chroot_dir} apt install -y openssh-server rdnssd linux-image-amd64 firmware-bnx2 ifenslave vlan chroot ${chroot_dir} apt install -y openssh-server rdnssd linux-image-amd64 firmware-bnx2 ifenslave vlan grub
echo "unconfigured-host" > ${chroot_dir}/etc/hostname echo "unconfigured-host" > ${chroot_dir}/etc/hostname
cp ${chroot_dir}/boot/vmlinuz-* ${kernel}
echo '* * * * * root ip -o -6 addr show | grep -E -v " lo |one" > /etc/issue' > ${chroot_dir}/etc/cron.d/ipv6addr echo '* * * * * root ip -o -6 addr show | grep -E -v " lo |one" > /etc/issue' > ${chroot_dir}/etc/cron.d/ipv6addr
mkdir -p ${chroot_dir}/root/.ssh mkdir -p ${chroot_dir}/root/.ssh
for key in sami dominique jinguk nico; do cat ${keyfile} > ${chroot_dir}/root/.ssh/authorized_keys
curl -s ${keyurl}/${key} >> ${chroot_dir}/root/.ssh/authorized_keys
done
# Fix possible permission issue from above # Fix possible permission issue from above
chown -R root:root ${chroot_dir}/root/ chmod -R og-rwx ${chroot_dir}/root/
################################################################################ ################################################################################
# networking # networking
@ -101,42 +100,19 @@ iface eth1 inet manual
bond-master bond0 bond-master bond0
post-up /sbin/ip link set \$IFACE mtu 9000 post-up /sbin/ip link set \$IFACE mtu 9000
# server network
auto bond0.11
iface bond0.11 inet6 auto
post-up /sbin/ip link set \$IFACE mtu 9000
vlan-raw-device bond0
EOF EOF
# # find the boot interfaces at boot: HP servers still have ifnames=1 for dir in dev sys proc; do
# cat > ${chroot_dir}/etc/rc.local <<EOF mount --bind /${dir} ${chroot_dir}/${dir}
# mac=\$(cat /proc/cmdline | tr ' ' '\n' | awk -F= '/bootdev/ { print \$2 }') done
# dev=\$(ip -o link | awk -F: "/\$mac/ { print \\\$2 }" | sed 's/ *//g')
# cat >> /etc/network/interfaces << eof chroot ${chroot_dir} grub-install ${disk}
# auto \$dev
# iface \$dev inet6 auto
# eof
# ifup "\${dev}" for dir in dev sys proc; do
umount ${chroot_dir}/${dir}
done
# exit 0 umount ${chroot_dir}
# EOF sync
# chmod a+rx "${chroot_dir}/etc/rc.local" rmdir ${chroot_dir}
# 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 -fs /sbin/init ${chroot_dir}/init
# Finally building the initramfs
( cd ${chroot_dir} ; find . | cpio -H newc -o | gzip -9 > ${initramfs} )
# Fix paranoid permissions
chmod a+rx ${abs_outdir}
chmod a+r ${kernel} ${initramfs}
exit 0