metal/bsp-files/kickstarts/post_net_controller.cfg
Tao Liu 5a44b5be49 Configurable Host HTTP/HTTPS Port Binding
Update pxeboot-update script to accept parameter for
installer base URL

Add a common function to parse the port number from
inst.repo

Update pxeboot and kickstart URLs to support a configurable
HTTP port

Story: 2004642
Task: 28593
Depends-On: https://review.openstack.org/#/c/634237/

Change-Id: Ibd66e89e49794ca57b938eb43d227860eda6674a
Signed-off-by: Tao Liu <tao.liu@windriver.com>
2019-02-06 16:04:07 -06:00

81 lines
3.0 KiB
INI

%post --erroronfail
# Source common functions
. /tmp/ks-functions.sh
http_port=$(get_http_port)
# Retrieve the installation uuid from the controller we booted from
INSTALL_UUID=`curl -sf http://pxecontroller:${http_port:-8080}/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid`
if [ $? -ne 0 ]
then
INSTALL_UUID=unknown
fi
grep -q INSTALL_UUID /etc/platform/platform.conf
if [ $? -ne 0 ]; then
echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf
fi
cd /www/pages
# Sync software repository
feed_url=http://pxecontroller:${http_port:-8080}/feed/
anaconda_logdir=/var/log/anaconda
mkdir -p $anaconda_logdir
echo "Mirroring software repository (may take several minutes)..." >/dev/console
wget --recursive --no-parent --no-host-directories --no-clobber --reject 'index.html*' --reject '*.log' $feed_url/ -o $anaconda_logdir/wget-feed-mirror.log \
|| report_post_failure_with_logfile $anaconda_logdir/wget-feed-mirror.log
# Sync patching repository
updates_url=http://pxecontroller:${http_port:-8080}/updates/
wget --mirror --no-parent --no-host-directories --reject 'index.html*' --reject '*.log' $updates_url/ -o $anaconda_logdir/wget-updates-mirror.log \
|| report_post_failure_with_logfile $anaconda_logdir/wget-updates-mirror.log
echo "Done" >/dev/console
shopt -s nullglob
# Check whether a second release is installed
. /etc/build.info
CURRENT_REL_DIR=rel-${SW_VERSION}
OTHER_REL_DIR=
for REL_DIR in /www/pages/feed/*; do
if [[ ! $REL_DIR =~ "${SW_VERSION}" ]]; then
OTHER_REL_DIR=`basename $REL_DIR`
OTHER_REL_VERSION=${OTHER_REL_DIR:4}
break
fi
done
# If second release is installed, find the latest version of the installer
# RPM and install the pxeboot files we require to boot hosts with that release.
if [ ! -z "$OTHER_REL_DIR" ]; then
PATCH_RPM=`find /www/pages/updates/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
BASE_RPM=`find /www/pages/feed/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
if [ ! -z "$PATCH_RPM" ]; then
INSTALL_RPM=$PATCH_RPM
elif [ ! -z "$BASE_RPM" ]; then
INSTALL_RPM=$BASE_RPM
else
report_post_failure_with_msg "ERROR: Unable to find pxe-network-installer RPM for $OTHER_REL_DIR. Aborting installation."
fi
echo "Installing pxeboot files for release $OTHER_REL_DIR from $INSTALL_RPM" >/dev/console
TMP_RPM=/tmp/pxe-network-installer
mkdir $TMP_RPM
pushd $TMP_RPM
/usr/bin/rpm2cpio $INSTALL_RPM | cpio -idm \
|| report_post_failure_with_msg "Failed to extract pxe-network-installer"
cp -r $TMP_RPM/usr / \
|| report_post_failure_with_msg "Failed to copy pxe-network-installer /usr"
cp -r $TMP_RPM/pxeboot/$OTHER_REL_DIR /pxeboot/ \
|| report_post_failure_with_msg "Failed to copy pxe-network-installer /pxeboot/$OTHER_REL_DIR"
cp $TMP_RPM/pxeboot/pxelinux.cfg.files/*-$OTHER_REL_VERSION /pxeboot/pxelinux.cfg.files/ \
|| report_post_failure_with_msg "Failed to copy pxe-network-installer pxelinux.cfg files"
rm -rf $TMP_RPM
fi
%end