2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-22 09:32:27 +00:00
Files
xcat-core/xCAT-genesis-builder/xcat-cmdline.sh
T
Daniel Hilst 0b31e2146e fix(xcat-core): the el10 Genesis image gives root the home directory /root
Every case that boots a node into the el10 legacy Genesis image fails with
"root@<cn>: Permission denied (publickey,password,keyboard-interactive)".
mknb writes the management node key to /.ssh/authorized_keys, and sshd looks
for it under the home directory of root.

The dracut cmdline hook deletes the root entry the image ships with
"sed -i '/^root:x/d'" and appends its own entry with the home directory /.
dracut 99base writes that entry, and from dracut 060 the password field holds
x only when the image is built --hostonly. The Genesis image is built with -N,
so el10 (dracut 107) ships "root::0:0::/root:/bin/sh". The delete does not
match, two root entries survive, and getpwnam returns the first one. el8
(dracut 049) and el9 (dracut 057) always ship the x and are not affected.

The delete now matches the user name only. All three cmdline hooks carry the
same statement and all three change.

genesis_root_home.t runs the rewrite against both entry shapes and fails on
the empty password field without this change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-05 00:36:55 -03:00

91 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
root=1
rootok=1
netroot=xcat
clear
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bashrc
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bash_profile
mkdir -p /etc/ssh
mkdir -p /var/tmp/
mkdir -p /var/empty/sshd
# dracut writes this entry itself, with an empty password field unless the image is
# built --hostonly. Match the user name only.
sed -i '/^root:/d' /etc/passwd
cat >>/etc/passwd <<"__ENDL"
root:x:0:0::/:/bin/bash
sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
chrony:x:995:991::/var/lib/chrony:/sbin/nologin
__ENDL
# Fedora 20 ppc64 uses /lib/dracut/hooks/initqueue/finished
# CentOS 7 probably uses /lib/dracut/hooks/initqueue/finished also
if [ -d "/initqueue-finished" ]; then
echo '[ -e $NEWROOT/proc ]' > /initqueue-finished/xcatroot.sh
else
#echo 'if [ -e /proc ]; then /bin/doxcat; fi' > /lib/dracut/hooks/initqueue/finished/xcatroot.sh
echo '[ -e /proc ]' > /lib/dracut/hooks/initqueue/finished/xcatroot.sh
fi
mkdir /dev/cgroup
mount -t cgroup -o cpu,memory,devices cgroup /dev/cgroup
# Fedora 20 ppc64 does not udevd
# CentOS 7 probably does not have udevd either
if [ -f "/sbin/udevd" ]; then
udevd --daemon
else
/usr/lib/systemd/systemd-udevd --daemon
fi
udevadm trigger
mkdir -p /var/lib/dhclient/
mkdir -p /var/log
ip link set lo up
echo '127.0.0.1 localhost' >> /etc/hosts
if grep -q console=ttyS /proc/cmdline; then
while :; do sleep 1; screen -S console -ln screen -x doxcat </dev/tty1 &>/dev/tty1; clear &>/dev/tty1 ; done &
fi
while :; do screen -ln < /dev/tty2 &> /dev/tty2 ; done &
# The section below is just for System P LE hardware discovery
ARCH="$(uname -m)"
if [[ ${ARCH} =~ ppc64 ]]; then
# Need to wait for NIC initialization (System P LE discovery only)
sleep 20
# load all network driver modules listed in /lib/modules/<kernel>/modules.dep file
KERVER=`uname -r`
for line in `cat /lib/modules/$KERVER/modules.dep | awk -F: '{print \$1}' | sed -e "s/\(.*\)\.ko.*/\1/"`; do
if [[ $line =~ "kernel/drivers/net" ]]; then
modprobe `basename $line`
fi
done
# Check if running on a VM, and load "virtio_pci" module
cat /proc/cpuinfo | grep "machine" | grep "emulated"
if [ $? -eq 0 ]; then
modprobe virtio_pci
fi
waittime=2
ALL_NICS=$(ip link show | grep -v "^ " | awk '{print $2}' | sed -e 's/:$//' | grep -v lo)
for tmp in $ALL_NICS; do
tmp_data="$(ip link show "$tmp" | grep -v "^ " | grep "UP")"
if [ "$tmp_data" == "" ]; then
ip link set "$tmp" up
fi
tmp_data="UP"
waittime=$((waittime+1))
done
# wait 2+number_of_nics seconds for all the LINKed NICs to be UP
sleep $waittime
elif [[ ${ARCH} =~ x86_64 ]]; then
# load all network driver modules listed in /lib/modules/<kernel>/modules.dep file
KERVER=`uname -r`
for line in `cat /lib/modules/$KERVER/modules.dep |grep -vE 'tunnel|ieee|ifb|bond|dummy|fjes|hv_netvsc|ntb_netdev|xen-netfront|hdlc_fr|dlci'| awk -F: '{print \$1}' | sed -e "s/\(.*\)\.ko.*/\1/"`; do
if [[ $line =~ "kernel/drivers/net" ]]; then
modprobe `basename $line`
fi
done
fi
while :; do screen -dr doxcat || screen -S doxcat -L -ln doxcat; done