diff --git a/bsp-files/centos-ks-gen.pl b/bsp-files/centos-ks-gen.pl index 469837b3..a3e5e061 100755 --- a/bsp-files/centos-ks-gen.pl +++ b/bsp-files/centos-ks-gen.pl @@ -120,7 +120,6 @@ write_config_file("controller-worker-lowlatency", "post_system_aio.cfg", "post_pxeboot_controller.cfg"); - # Write same net files write_config_file("controller", "${output_dir}/net_controller_ks.cfg", @@ -206,6 +205,46 @@ write_config_file("storage", "post_lvm_pv_on_rootfs.cfg", "post_net_common.cfg"); +# Write miniboot files +write_config_file("controller", + "${output_dir}/miniboot_controller_ks.cfg", + "pre_common_head.cfg", + "pre_pkglist.cfg", + "pre_disk_setup_common.cfg", + "pre_disk_controller.cfg", + "pre_disk_setup_tail.cfg", + "post_platform_conf_controller.cfg", + "post_common.cfg", + "post_kernel_controller.cfg", + "post_lvm_pv_on_rootfs.cfg", + "post_miniboot_controller.cfg"); +write_config_file("controller-worker", + "${output_dir}/miniboot_smallsystem_ks.cfg", + "pre_common_head.cfg", + "pre_pkglist.cfg", + "pre_disk_setup_common.cfg", + "pre_disk_aio.cfg", + "pre_disk_setup_tail.cfg", + "post_platform_conf_aio.cfg", + "post_common.cfg", + "post_kernel_aio_and_worker.cfg", + "post_lvm_pv_on_rootfs.cfg", + "post_system_aio.cfg", + "post_miniboot_controller.cfg"); +write_config_file("controller-worker-lowlatency", + "${output_dir}/miniboot_smallsystem_lowlatency_ks.cfg", + "pre_common_head.cfg", + "pre_pkglist_lowlatency.cfg", + "pre_disk_setup_common.cfg", + "pre_disk_aio.cfg", + "pre_disk_setup_tail.cfg", + "post_platform_conf_aio_lowlatency.cfg", + "post_common.cfg", + "post_kernel_aio_and_worker.cfg", + "post_lvm_pv_on_rootfs.cfg", + "post_system_aio.cfg", + "post_miniboot_controller.cfg"); + system("mkdir -p ${extra_output_dir}"); # write Ottawa Lab files diff --git a/bsp-files/kickstarts/post_miniboot_controller.cfg b/bsp-files/kickstarts/post_miniboot_controller.cfg new file mode 100644 index 00000000..b19059f8 --- /dev/null +++ b/bsp-files/kickstarts/post_miniboot_controller.cfg @@ -0,0 +1,316 @@ +%pre --erroronfail + +# Source common functions +. /tmp/ks-functions.sh + +BACKUP_PART_LABEL=Platform\\x20Backup +BACKUP_DEVICE=/dev/disk/by-partlabel/${BACKUP_PART_LABEL} +BACKUP_MOUNT=/mnt/platform-backup +BOOTIMAGE_ISO=${BACKUP_MOUNT}/xxxPLATFORM_RELEASExxx/bootimage.iso +BOOTIMAGE_MD5=${BACKUP_MOUNT}/xxxPLATFORM_RELEASExxx/bootimage.md5 +BOOTIMAGE_MOUNT=/mnt/bootimage +KS="Miniboot pre:" + +wlog "$KS local install check" + +# Look for and validate the local iso image +if [ -e ${BACKUP_DEVICE} ]; then + mkdir -p ${BACKUP_MOUNT} + mount ${BACKUP_DEVICE} ${BACKUP_MOUNT} 2>/dev/null + if [ -f ${BOOTIMAGE_ISO} ]; then + wlog "$KS local iso found : ${BOOTIMAGE_ISO}" + + # ISO Validity Check + if [ -f ${BOOTIMAGE_MD5} ] ; then + md5sum -c ${BOOTIMAGE_MD5} >> /tmp/isocheck 2>> /tmp/isocheck + if [ $? -eq 0 ] ; then + mkdir -p ${BOOTIMAGE_MOUNT} + mount -o loop ${BOOTIMAGE_ISO} ${BOOTIMAGE_MOUNT} + wlog "$KS local iso verified and mounted" + else + wlog "$KS local iso check failed" + fi + else + wlog "$KS local iso check file missing : ${BOOTIMAGE_MD5}" + fi + else + wlog "$KS local iso file not found : ${BOOTIMAGE_ISO}" + fi +fi + +cat << EOF > /tmp/repo-include +repo --name=local-base --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/ +repo --name=local-updates --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/patches/ +repo --name=remote-base --cost=200 --baseurl=xxxHTTP_URLxxx/ +repo --name=remote-updates --cost=200 --baseurl=xxxHTTP_URLxxx/patches/ +EOF +%end + +# Repository arguments from %pre +%include /tmp/repo-include + + +%post --erroronfail + +# Source common functions +. /tmp/ks-functions.sh + +KS="Miniboot post:" + +wlog "$KS cmdLine: $(cat /proc/cmdline)" +if [ -e /dev/disk/by-label/oe_iso_boot ]; then + # This is a hybrid ISO/network install. Mount the media to ensure Anaconda + # ejects it on reboot. + mkdir /mnt/iso + wlog "$KS mount for eject" + mount /dev/disk/by-label/oe_iso_boot /mnt/iso +else + wlog "$KS /dev/disk/by-label/oe_iso_boot does not exist" +fi + +# persist the default http port number to platform configuration. This +# will get overwritten when config_controller is run. +echo http_port=8080 >> /etc/platform/platform.conf + +# Build networking scripts +cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo +DEVICE=lo +IPADDR=127.0.0.1 +NETMASK=255.0.0.0 +NETWORK=127.0.0.0 +BROADCAST=127.255.255.255 +ONBOOT=yes +IPV6_AUTOCONF=no +NAME=loopback +EOF + +%end + +%post --nochroot --erroronfail + +# Source common functions +. /tmp/ks-functions.sh + +# Mirror local software repositories +SYSIMAGE_MOUNT=/mnt/sysimage +FEED_DIR=${SYSIMAGE_MOUNT}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx +UPDATES_DIR=${SYSIMAGE_MOUNT}/www/pages/updates/rel-xxxPLATFORM_RELEASExxx +PATCHING_DIR=${SYSIMAGE_MOUNT}/opt/patching +PACKAGES_DIR=${PATCHING_DIR}/packages/xxxPLATFORM_RELEASExxx/ + +KS="Miniboot post:" + +log_count=0 + +if [ -d ${SYSIMAGE_MOUNT} ] ; then + + files="$(ls -lrt ${SYSIMAGE_MOUNT})" + wlog "$KS ${SYSIMAGE_MOUNT} files : $files[@]" + if [ -d ${FEED_DIR} ] ; then + files=$(ls -lrt ${FEED_MOUNT}) + wlog "$KS $FEED_DIR files : $files[@]" + else + wlog "$KS error : feed dir '$FEED_DIR' does not exist" + fi + + # Check updates Dir + if [ -d ${UPDATES_DIR} ] ; then + files=$(ls -lrt ${UPDATES_DIR}) + wlog "$KS $UPDATES_DIR files : $files[@]" + else + wlog "$KS $UPDATES_DIR does not exist" + fi + + # Check Packages Dir + if [ -d ${PATCHING_DIR} ] ; then + files=$(ls -lrt ${PATCHING_DIR}) + wlog "$KS $PATCHING_DIR files : $files[@]" + + if [ -d ${PATCHING_DIR}/metadata ] ; then + files=$(ls -lrt ${PATCHING_DIR}/metadata) + wlog "$KS $PATCHING_DIR/metadata files : $files[@]" + + if [ -d ${PATCHING_DIR}/metadata/applied ] ; then + files=$(ls -lrt ${PATCHING_DIR}/metadata/applied) + wlog "$KS $PATCHING_DIR/metadata/applied files : $files[@]" + else + wlog "$KS $PATCHING_DIR/metadata/applied does not exist" + fi + if [ -d ${PATCHING_DIR}/metadata/available ] ; then + files=$(ls -lrt ${PATCHING_DIR}/metadata/available) + wlog "$KS $PATCHING_DIR/metadata/available files : $files[@]" + else + wlog "$KS $PATCHING_DIR/metadata/available does not exist" + fi + else + wlog "$KS $PATCHING_DIR/metadata does not exist" + fi + else + wlog "$KS $PATCHING_DIR does not exist" + fi + + # Check Packages Dir + if [ -d ${PACKAGES_DIR} ] ; then + files=$(ls -lrt ${PACKAGES_DIR}) + wlog "$KS $PACKAGES_DIR files : $files[@]" + else + wlog "$KS $PACKAGES_DIR does not exist" + fi + +else + wlog "$KS Error : $SYSIMAGE_MOUNT does not exists or is not a directory" +fi + + +# Decide on install mode ; local or remote +if [ -d /mnt/bootimage ]; then + srcdir=/mnt/bootimage + wlog "$KS local install - ${srcdir}" +else + # Remote System Controller + srcdir=/mnt/install/source + wlog "$KS remote install - ${srcdir}" +fi + +if [ -d $srcdir/Packages ] ; then + wlog "$KS copying software repository $srcdir/Packages" + mkdir -p ${FEED_DIR} + cp -r $srcdir/Packages ${FEED_DIR}/Packages + if [ -d $srcdir/repodata ] ; then + cp -r $srcdir/repodata ${FEED_DIR}/repodata + else + wlog "$KS $srcdir/repodata dir does not exist" + fi +fi + +if [ -d $srcdir/patches ]; then + if [ -d $srcdir/patches/Packages ] ; then + wlog "$KS copying patch Packages $srcdir/patches/Packages" + mkdir -p ${UPDATES_DIR} + cp -r $srcdir/patches/Packages ${UPDATES_DIR}/Packages + else + wlog "$KS $srcdir/patches/Packages does not exist" + fi + + if [ -d $srcdir/patches/repodata ] ; then + wlog "$KS copying patch repository $srcdir/patches/repodata" + mkdir -p ${UPDATES_DIR} + cp -r $srcdir/patches/repodata ${UPDATES_DIR}/repodata + else + wlog "$KS $srcdir/patches/repodata does not exist" + fi +fi + +if [ -d $srcdir/patches/metadata ] ; then + mkdir -p ${PATCHING_DIR} + wlog "$KS copying $srcdir/patches/metadata to ${PATCHING_DIR}" + cp -r $srcdir/patches/metadata ${PATCHING_DIR}/metadata +fi + +if [ -d $srcdir/patches ]; then + mkdir -p ${PACKAGES_DIR} + wlog "$KS copying packages" + find ${UPDATES_DIR}/Packages -name '*.rpm' \ + | xargs --no-run-if-empty -I files cp --preserve=all files ${PACKAGES_DIR} +fi + +%end + + +%post --erroronfail + +# Source common functions +. /tmp/ks-functions.sh + +KS="Miniboot post:" + +# Create a uuid specific to this installation +INSTALL_UUID=`uuidgen` +echo $INSTALL_UUID > /www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid +echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf +wlog "$KS updating platform.conf with install uuid : ${INSTALL_UUID}" + +# Mirror remote software repositories +anaconda_logdir=/var/log/anaconda +mkdir -p $anaconda_logdir + +# Check for inst.noverifyssl +if grep -q inst.noverifyssl /proc/cmdline; then + NOVERIFYSSL_WGET_OPT="--no-check-certificate" +else + NOVERIFYSSL_WGET_OPT="" +fi + + +# If the patch to $FEED_DIR does not exist then proceed to create it and +# fetch the ISO content in pieces from the system controller: +# +# - Packages +# - Repodata +# - Patch Packages +# - Patches repodata +# - Patches metadata +# - Save all patch packages to /opt/patching/packages/xxxPLATFORM_RELEASExxx +# +FEED_DIR=/www/pages/feed/rel-xxxPLATFORM_RELEASExxx +wlog "$KS feed dir $FEED_DIR" +if [ -d ${FEED_DIR} ]; then + mkdir -p ${FEED_DIR}/Packages + mkdir -p ${FEED_DIR}/repodata + cd ${FEED_DIR} + feed_url=xxxHTTP_URLxxx + declare -i cut_dirs=NUM_DIRS + + wlog "$KS downloading software repository $feed_url" + + # Fetch Packages + wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ + --cut-dirs=$cut_dirs $feed_url/Packages/ -o $anaconda_logdir/rpmget.log \ + || report_post_failure_with_logfile $anaconda_logdir/rpmget.log + + # Fetch Repodata + wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ + --cut-dirs=$cut_dirs $feed_url/repodata/ -o $anaconda_logdir/rpmget_repo.log \ + || report_post_failure_with_logfile $anaconda_logdir/rpmget_repo.log + + # Fetch Patch Package Data quietly + patches_url=xxxHTTP_URLxxx/patches + wget ${NOVERIFYSSL_WGET_OPT} -q --spider ${patches_url}/ + if [ $? -eq 0 ]; then + wlog "$KS downloading patch repository $patches_url" + cd /www/pages + mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/Packages + mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/repodata + cd updates/rel-xxxPLATFORM_RELEASExxx + declare -i patches_cut_dirs=$((cut_dirs+1)) + + wlog "$KS fetch packages" + wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ + --cut-dirs=$patches_cut_dirs $patches_url/Packages/ -o $anaconda_logdir/patches_rpmget.log \ + || report_post_failure_with_logfile $anaconda_logdir/patches_rpmget.log + + wlog "$KS fetch package repodata" + wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ + --cut-dirs=$patches_cut_dirs $patches_url/repodata/ -o $anaconda_logdir/patches_rpmget_repo.log \ + || report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_repo.log + + mkdir -p /opt/patching/metadata + mkdir -p /opt/patching/packages/xxxPLATFORM_RELEASExxx + cd /opt/patching + + wlog "$KS fetch patch metadata" + wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ + --cut-dirs=$patches_cut_dirs $patches_url/metadata/ -o $anaconda_logdir/patches_rpmget_metadata.log \ + || report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_metadata.log + + wlog "$KS save a copy of all patch packages, preserve attributes" + find /www/pages/updates/rel-xxxPLATFORM_RELEASExxx/Packages -name '*.rpm' \ + | xargs --no-run-if-empty -I files cp --preserve=all files /opt/patching/packages/xxxPLATFORM_RELEASExxx/ + else + wlog "$KS get from patches url '$patches_url' failed" + fi +else + wlog "$KS feed dir $FEED_DIR does not exist" +fi + +%end