2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-19 08:52:20 +00:00
Files
confluent/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage
T
Markus Hilger e23873888f Serve installtodisk syncfiles with the sshd of the image
After image2disk, installimage stopped the sshd of the image and moved
port 22 to the initramfs sshd, chrooted into the install target, by
sending that sshd HUP. The el9 initramfs only starts its sshd with
debugssh, and on EL 9.8 it cannot start at all without sshd-session, so
normally nothing listened on port 22. The syncfiles push of post.sh then
failed with connection refused while the node still reported completed.

Restart the sshd of the image instead, chrooted into the install target.
It is always present and matches the OpenSSH helpers of the image, so
this also works for images packed or captured before the initramfs fix.
Wait for the old sshd to exit first, so the new one can bind port 22.
2026-11-09 20:26:06 +01:00

64 lines
2.8 KiB
Bash

#!/bin/bash
. /etc/confluent/functions
# the image will be used to deploy itself
# provide both access to image (for parsing metadata)
# and existing mounts of image (to take advantage of caching)
mount -o bind /sys /sysroot/sys
mount -o bind /dev /sysroot/dev
mount -o bind /dev/pts /sysroot/dev/pts
mount -o bind /proc /sysroot/proc
mount -o bind /run /sysroot/run
mount -t efivarfs none /sysroot/sys/firmware/efi/efivars
if [ ! -f /tmp/mountparts.sh ]; then
mkdir -p /sysroot/run/imginst/sources/_
mount -o bind /mnt/remote /sysroot/run/imginst/sources/_
else
for srcmount in $(cat /tmp/mountparts.sh | awk '{print $2}'); do
srcname=${srcmount#/dev/mapper/mproot}
srcdir=$(echo $srcmount | sed -e 's!/dev/mapper/mproot!/mnt/remote!' -e 's!_!/!g')
mkdir -p /sysroot/run/imginst/sources/$srcname
mount -o bind $srcdir /sysroot/run/imginst/sources/$srcname
done
fi
cd /sysroot/run
chmod 0600 /sysroot/etc/ssh/ssh*key
chroot /sysroot/ bash -c "/usr/sbin/sshd"
chroot /sysroot/ bash -c "source /etc/confluent/functions; run_remote_python getinstalldisk"
chroot /sysroot/ bash -c "source /etc/confluent/functions; run_remote_parts pre.d"
for nameserver in $(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //'); do
echo "nameserver $nameserver" >> /sysroot/etc/resolv.conf
done
if [ ! -f /sysroot/tmp/installdisk ]; then
echo 'Unable to find a suitable installation target device, ssh to port 2222 to investigate'
while [ ! -f /sysroot/tmp/installdisk ]; do
sleep 1
done
fi
if command -v lvm > /dev/null; then lvm vgchange -a n; fi # lvm is optional in the initramfs
/sysroot/usr/sbin/wipefs -a /dev/$(cat /sysroot/tmp/installdisk)
udevadm control -e
if [ -f /sysroot/etc/lvm/devices/system.devices ]; then
rm /sysroot/etc/lvm/devices/system.devices
fi
chroot /sysroot /usr/lib/systemd/systemd-udevd --daemon
chroot /sysroot bash -c "source /etc/confluent/functions; run_remote_python image2disk.py"
sshdpid=$(cat /sysroot/var/run/sshd.pid)
kill $sshdpid
# wait for the old sshd to release port 22
for i in {1..50}; do kill -0 $sshdpid 2> /dev/null || break; sleep 0.1; done
# Serve the install target on port 22 for the syncfiles push of post.sh. Use
# the sshd of the image: the initramfs sshd only runs with debugssh and may
# lack helpers of the image's OpenSSH version, like sshd-session
chroot /sysroot /usr/sbin/sshd -p 22 -o ChrootDirectory=/run/imginst/targ
cp /sysroot/etc/pki/ca-trust/source/anchors/* /sysroot/run/imginst/targ/etc/pki/ca-trust/source/anchors/
chroot /sysroot/run/imginst/targ update-ca-trust
chroot /sysroot/run/imginst/targ bash -c "source /etc/confluent/functions; run_remote post.sh"
chroot /sysroot bash -c "umount \$(tac /proc/mounts|awk '{print \$2}'|grep ^/run/imginst/targ)"