2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-05 20:47:55 +00:00
Files
xcat-core/xCAT-server/share/xcat/netboot/ubuntu/compute.postinstall
T
Daniel Hilst 3a5cbef630 fix(xcat-server): stop Ubuntu diskless images carrying the builder's identity
The Ubuntu netboot image inherited the build host's /etc/hostname --
genimage's chroot shares the build host's UTS namespace, so /etc/hostname
ended up as the MN's name and every diskless node booted as that name
instead of its own ("hostname poisoning"). xCAT keys on IP/MAC so
provisioning still succeeds, but the node's local identity (hostname,
prompt, syslog) is wrong and N nodes share one name. The image also
shipped no netplan, so systemd-networkd-wait-online failed. In
compute.postinstall, clear /etc/hostname so each node takes its name at
boot from DHCP (udhcpc option host-name) / xCAT, and drop in a DHCP
netplan (optional, dhcp-identifier mac) so systemd-networkd configures the
boot NIC. Ubuntu-only.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-06-24 14:20:27 -03:00

78 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
#-- Do not remove following line if you want to make use of CVS version tracking
#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $
#-- jurij.sikorsky@t-systems.cz
#--
#-- this script is run after all packages from $profile.pkglist are installed
#--
#-- it gets these arguments:
#--
#-- $1 = install root (chroot directory for profile)
#-- $2 = OS version
#-- $3 = architecture
#-- $4 = profile name
#-- $5 = work dir (where genimage is located)
#--
#--
installroot=$1
osver=$2
arch=$3
profile=$4
workdir=$5
#-- Example how /etc/fstab can be automatically generated during image generation:
cat <<END >$installroot/etc/fstab
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 2
tmpfs /var/tmp tmpfs defaults 0 2
${profile}_${arch} / tmpfs rw 0 1
END
#-- Uncomment the line contains "cons" in /etc/inittab
#-- Example of booted image versioning
#-- We want to know, with what configuration (version of the image) each node was booted.
#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run.
#cat /dev/null > $installroot/etc/IMGVERSION
#for ext in pkglist exlist postinstall repolist; do
# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION
#done
#Setup locale for Ubuntu diskless nodes
echo "Setting up the locales";
chroot $installroot \
locale-gen en_US.UTF-8 en_US
chroot $installroot \
update-locale
DEBIAN_FRONTEND=noninteractive chroot $installroot \
dpkg-reconfigure locales
#-- A shared diskless image must not carry the builder's identity. genimage's chroot shares
#-- the build host's UTS namespace, so /etc/hostname ends up as the MN's name and every node
#-- booting this image inherits it ("hostname poisoning"). Clear it so each node takes its name
#-- at boot from DHCP (udhcpc option host-name) / xCAT instead of the build host.
: > $installroot/etc/hostname
#-- Ship a DHCP netplan so systemd-networkd configures the boot NIC. Without any netplan in the
#-- image, systemd-networkd-wait-online has nothing to bring up and the unit fails. optional:true
#-- keeps it from blocking boot; dhcp-identifier:mac matches xCAT's MAC-based DHCP.
mkdir -p $installroot/etc/netplan
cat <<'NETPLAN' > $installroot/etc/netplan/90-xcat-dhcp.yaml
network:
version: 2
renderer: networkd
ethernets:
xcat-cluster:
match:
name: "e*"
dhcp4: true
dhcp-identifier: mac
optional: true
NETPLAN
chmod 600 $installroot/etc/netplan/90-xcat-dhcp.yaml