2 # Copyright (c) 2019 Wind River Systems, Inc.
3 # SPDX-License-Identifier: Apache-2.0
7 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
8 # . /tmp/ks-functions.sh
11 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
13 # Copyright (c) 2019 Wind River Systems, Inc.
15 # SPDX-License-Identifier: Apache-2.0
18 function get_by_path()
20 local disk=\$(cd /dev ; readlink -f \$1)
21 for p in /dev/disk/by-path/*; do
22 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
31 echo \$(cd /dev ; readlink -f \$1)
34 function report_pre_failure_with_msg()
37 echo -e '\n\nInstallation failed.\n'
43 function report_post_failure_with_msg()
46 cat <<EOF >> /etc/motd
52 echo "\$msg" >/etc/platform/installation_failed
54 echo -e '\n\nInstallation failed.\n'
60 function report_post_failure_with_logfile()
63 cat <<EOF >> /etc/motd
66 Please see \$logfile for details of failure
69 echo \$logfile >/etc/platform/installation_failed
71 echo -e '\n\nInstallation failed.\n'
77 function get_http_port()
79 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
87 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
88 # . /tmp/ks-functions.sh
91 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
93 # Copyright (c) 2019 Wind River Systems, Inc.
95 # SPDX-License-Identifier: Apache-2.0
98 function get_by_path()
100 local disk=\$(cd /dev ; readlink -f \$1)
101 for p in /dev/disk/by-path/*; do
102 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
111 echo \$(cd /dev ; readlink -f \$1)
114 function report_pre_failure_with_msg()
117 echo -e '\n\nInstallation failed.\n'
123 function report_post_failure_with_msg()
126 cat <<EOF >> /etc/motd
132 echo "\$msg" >/etc/platform/installation_failed
134 echo -e '\n\nInstallation failed.\n'
140 function report_post_failure_with_logfile()
143 cat <<EOF >> /etc/motd
146 Please see \$logfile for details of failure
149 echo \$logfile >/etc/platform/installation_failed
151 echo -e '\n\nInstallation failed.\n'
157 function get_http_port()
159 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
167 # Template from: pre_common_head.cfg
170 # Source common functions
171 . /tmp/ks-functions.sh
173 # First, parse /proc/cmdline to find the boot args
174 set -- `cat /proc/cmdline`
175 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
178 if [ -n "$console" ] ; then
179 append="console=$console"
182 if [ -n "$security_profile" ]; then
183 append="$append security_profile=$security_profile"
186 #### SECURITY PROFILE HANDLING (Pre Installation) ####
187 if [ -n "$security_profile" ] && [ "$security_profile" == "extended" ]; then
188 # IMA specific boot options:
189 # Enable Kernel auditing
190 append="$append audit=1"
192 # we need to blacklist the IMA and Integrity Modules
193 # on standard security profile
194 append="$append module_blacklist=integrity,ima"
196 # Disable Kernel auditing in Standard Security Profile mode
197 append="$append audit=0"
200 if [ -n "$tboot" ]; then
201 append="$append tboot=$tboot"
203 append="$append tboot=false"
207 if [ -n "$boot_device" ] ; then
208 boot_device_arg="--boot-drive=$(get_by_path $boot_device)"
211 echo "bootloader --location=mbr $boot_device_arg --timeout=5 --append=\"$append\"" > /tmp/bootloader-include
213 echo "timezone --nontp --utc UTC" >/tmp/timezone-include
220 %include /tmp/timezone-include
221 # set to 'x' so we can use shadow password
224 authconfig --enableshadow --passalgo=sha512
225 firewall --service=ssh
227 # The following is the partition information you requested
228 # Note that any partitions you deleted are not expressed
229 # here so unless you clear all partitions first, this is
230 # not guaranteed to work
233 # Disk layout from %pre
234 %include /tmp/part-include
235 # Bootloader parms from %pre
236 %include /tmp/bootloader-include
241 # Template from: pre_net_common.cfg
244 # Setup ntp.conf and sync time
245 cat <<EOF >/etc/ntp_kickstart.conf
249 /usr/sbin/ntpd -g -q -n -c /etc/ntp_kickstart.conf
250 if [ $? -eq 0 ]; then
251 /sbin/hwclock --systohc --utc
257 # Template from: pre_pkglist_lowlatency.cfg
261 -kernel-module-igb-uio
262 -kernel-module-wrs-avp
273 -mlnx-ofa_kernel-modules
275 @platform-worker-lowlatency
276 @updates-worker-lowlatency
280 # Template from: pre_disk_setup_common.cfg
283 # Source common functions
284 . /tmp/ks-functions.sh
286 # This is a really fancy way of finding the first usable disk for the
287 # install and not stomping on the USB device if it comes up first
289 # First, parse /proc/cmdline to find the boot args
290 set -- `cat /proc/cmdline`
291 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
293 # Find either the ISO or USB device first chopping off partition
294 ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot`
295 sdev=`echo $ISO_DEV | sed -e 's/.$//'`
296 if [ -e /dev/disk/by-label/$sdev ] ; then
299 USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot`
300 sdev=`echo $USB_DEV | sed -e 's/.$//'`
301 if [ -e /dev/disk/by-label/$sdev ] ; then
305 # Temporary, until lab pxelinux.cfg files are updated to specify install devices
306 if [ -z "$rootfs_device" -o -z "$boot_device" ]
309 # Prefer a vd* device if this is kvm/qemu
310 for e in vda vdb sda sdb nvme0n1; do
311 if [ -e /dev/$e -a "$ISO_DEV" != "../../$e" -a "$USB_DEV" != "../../$e" ] ; then
317 # Set variables to $INST_HDD if not set
318 rootfs_device=${rootfs_device:-$INST_HDD}
319 boot_device=${boot_device:-$INST_HDD}
323 orig_rootfs_device=$rootfs_device
324 rootfs_device=$(get_by_path $rootfs_device)
326 orig_boot_device=$boot_device
327 boot_device=$(get_by_path $boot_device)
329 if [ ! -e "$rootfs_device" -o ! -e "$boot_device" ] ; then
330 # Touch this file to prevent Anaconda from dying an ungraceful death
331 touch /tmp/part-include
333 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is invalid."
336 # Ensure specified device is not a USB drive
337 udevadm info --query=property --name=$rootfs_device |grep -q '^ID_BUS=usb' || \
338 udevadm info --query=property --name=$boot_device |grep -q '^ID_BUS=usb'
339 if [ $? -eq 0 ]; then
340 # Touch this file to prevent Anaconda from dying an ungraceful death
341 touch /tmp/part-include
343 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is a USB drive."
346 # Deactivate existing volume groups to avoid Anaconda issues with pre-existing groups
347 vgs --noheadings -o vg_name | xargs --no-run-if-empty -n 1 vgchange -an
349 # Remove volumes and group for cgts-vg, if any
350 lvremove --force cgts-vg
351 pvs --select 'vg_name=cgts-vg' --noheadings -o pv_name | xargs --no-run-if-empty pvremove --force --force --yes
352 vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
355 if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
356 # In an upgrade, only wipe the disk with the rootfs and boot partition
357 echo "In upgrade, wiping only $rootfs_device"
358 WIPE_HDD="$(get_disk $rootfs_device)"
359 ONLYUSE_HDD="$(basename $(get_disk $rootfs_device))"
360 if [ "$(get_disk $rootfs_device)" != "$(get_disk $boot_device)" ]; then
361 WIPE_HDD="$WIPE_HDD,$(get_disk $boot_device)"
362 ONLYUSE_HDD="$ONLYUSE_HDD,$(basename $(get_disk $boot_device))"
365 # Make a list of all the hard drives that are to be wiped
367 # Partition type OSD has a unique globally identifier
368 part_type_guid_str="Partition GUID code"
369 CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
371 # Check if we wipe OSDs
372 if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
373 echo "Wipe OSD data."
374 WIPE_CEPH_OSDS="true"
376 echo "Skip Ceph OSD data wipe."
377 WIPE_CEPH_OSDS="false"
380 for f in /dev/disk/by-path/*
382 dev=$(readlink -f $f)
383 lsblk --nodeps --pairs $dev | grep -q 'TYPE="disk"'
389 # Avoid wiping USB drives
390 udevadm info --query=property --name=$dev |grep -q '^ID_BUS=usb' && continue
392 # Avoid wiping ceph osds if sysinv tells us so
393 if [ ${WIPE_CEPH_OSDS} == "false" ]; then
395 part_numbers=( `parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
396 # Scanning the partitions looking for CEPH OSDs and
397 # skipping any disk found with such partitions
398 for part_number in "${part_numbers[@]}"; do
399 sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
400 part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
401 if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
402 echo "OSD found on $dev, skipping wipe"
407 if [ "$wipe_dev" == "false" ]; then
412 # Add device to the wipe list
413 devname=$(basename $dev)
414 if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ]; then
415 if [ -n "$WIPE_HDD" ]; then
416 WIPE_HDD=$WIPE_HDD,$dev
422 echo "Not in upgrade, wiping disks: $WIPE_HDD"
425 for dev in ${WIPE_HDD//,/ }
427 # Clearing previous GPT tables or LVM data
428 # Delete the first few bytes at the start and end of the partition. This is required with
429 # GPT partitions, they save partition info at the start and the end of the block.
430 # Do this for each partition on the disk, as well.
431 partitions=$(lsblk -rip $dev -o TYPE,NAME |awk '$1 == "part" {print $2}')
432 for p in $partitions $dev
434 echo "Pre-wiping $p from kickstart"
435 dd if=/dev/zero of=$p bs=512 count=34
436 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
440 # Check for remaining cgts-vg PVs, which could potentially happen
441 # in an upgrade where we're not wiping all disks.
442 # If we ever create other volume groups from kickstart in the future,
443 # include them in this search as well.
444 partitions=$(pvs --select 'vg_name=cgts-vg' -o pv_name --noheading | grep -v '\[unknown\]')
447 echo "Pre-wiping $p from kickstart (cgts-vg present)"
448 dd if=/dev/zero of=$p bs=512 count=34
449 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
452 let -i gb=1024*1024*1024
454 cat<<EOF>/tmp/part-include
455 clearpart --all --drives=$WIPE_HDD --initlabel
458 if [ -n "$ONLYUSE_HDD" ]; then
459 cat<<EOF>>/tmp/part-include
460 ignoredisk --only-use=$ONLYUSE_HDD
464 if [ -d /sys/firmware/efi ] ; then
465 cat<<EOF>>/tmp/part-include
466 part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
469 cat<<EOF>>/tmp/part-include
470 part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
475 # Template from: pre_disk_worker.cfg
477 SCRATCH_VOL_SIZE=4000
480 ## LOG_VOL_SIZE = 4096
481 ## SCRATCH_VOL_SIZE = 4096
484 ## KUBELET_VOL_SIZE = 10240
485 ## RESERVED_PE = 16 (based on pesize=32768)
487 ## CGTS_PV_SIZE = 4096 + 4096 + 30720 + 20480 + 10240 + 16 = 69648
489 ## Round CGTS_PV_SIZE to the closest upper value that can be divided by 1024.
490 ## 69648/1024=68.01. CGTS_PV_SIZE=69*1024=70656.
493 sz=$(blockdev --getsize64 $(get_disk $rootfs_device))
494 if [ $sz -le $((80*$gb)) ] ; then
495 ## Less than 80GB use a 10GB root partition
498 ## Use a 20GB root partition
502 ROOTFS_OPTIONS="defaults"
503 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
504 if [ -n "$profile_mode" ]; then
505 # Enable iversion labelling for rootfs when IMA is enabled
506 ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
509 cat<<EOF>>/tmp/part-include
510 part /boot --fstype=ext4 --asprimary --size=$BOOT_VOL_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
511 part pv.253004 --asprimary --size=$CGTS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
512 volgroup cgts-vg --pesize=32768 pv.253004
513 logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
514 logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
515 part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
522 # Template from: post_platform_conf_worker_lowlatency.cfg
525 # Source common functions
526 . /tmp/ks-functions.sh
528 # Retrieve the installation uuid from the controller we booted from
529 http_port=$(get_http_port)
530 INSTALL_UUID=`curl -sf http://pxecontroller:${http_port:-8080}/feed/rel-19.12/install_uuid`
536 # Set the security profile mode
537 secprofile="standard"
538 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
539 if [ -n "$profile_mode" ]; then
540 secprofile="extended"
543 mkdir -p -m 0775 /etc/platform
544 cat <<EOF > /etc/platform/platform.conf
546 subfunction=worker,lowlatency
548 security_profile=$secprofile
549 INSTALL_UUID=$INSTALL_UUID
552 # mount the platform directory from the controller
553 cat >> /etc/fstab <<EOF
554 controller-platform-nfs:/opt/platform /opt/platform nfs timeo=30,udp,rsize=1024,wsize=1024,_netdev 0 0
559 # Template from: post_common.cfg
562 # Source common functions
563 . /tmp/ks-functions.sh
565 # Turn off locale support for i18n if is not installed
566 if [ ! -d /usr/share/i18n ] ; then
567 rm -f /etc/sysconfig/i18n
572 # If using a serial install make sure to add a getty on the tty1
573 conarg=`cat /proc/cmdline |xargs -n1 echo |grep console= |grep ttyS`
574 if [ -n "$conarg" ] ; then
575 echo "1:2345:respawn:/sbin/mingetty tty1" >> /etc/inittab
578 #### SECURITY PROFILE HANDLING (Post Installation) ####
579 # Check if the Security profile mode is enabled
580 # and load the appropriate kernel modules
581 secprofile=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
582 if [ -n "$secprofile" ]; then
583 echo "In Extended Security profile mode. Loading IMA kernel module"
584 systemctl enable auditd.service
585 # Add the securityfs mount for the IMA Runtime measurement list
586 echo "securityfs /sys/kernel/security securityfs defaults,nodev 0 0" >> /etc/fstab
588 # Disable audit daemon in the Standard Security Profile
589 systemctl disable auditd
592 . /etc/platform/platform.conf
593 # Configure smart package manager channels
594 rm -rf /var/lib/smart
596 /usr/bin/smart channel -y \
597 --add rpmdb type=rpm-sys name="RPM Database"
598 /usr/bin/smart channel -y \
599 --add base type=rpm-md name="Base" baseurl=http://controller:${http_port:-8080}/feed/rel-19.12
600 /usr/bin/smart channel -y \
601 --add updates type=rpm-md name="Patches" baseurl=http://controller:${http_port:-8080}/updates/rel-19.12
603 # Configure smart to use rpm --nolinktos option
604 /usr/bin/smart config --set rpm-nolinktos=true
606 # Configure smart to use rpm --nosignature option
607 /usr/bin/smart config --set rpm-check-signatures=false
609 # Delete the CentOS yum repo files
610 rm -f /etc/yum.repos.d/CentOS-*
612 # Persist the boot device naming as UDEV rules so that if the network device
613 # order changes post-install that we will still be able to DHCP from the
614 # correct interface to reach the active controller. For most nodes only the
615 # management/boot interface needs to be persisted but because we require both
616 # controllers to be identically configured and controller-0 and controller-1
617 # are installed differently (e.g., controller-0 from USB and controller-1 from
618 # network) it is not possible to know which interface to persist for
619 # controller-0. The simplest solution is to persist all interfaces.
621 mkdir -p /etc/udev/rules.d
622 echo "# Persisted network interfaces from anaconda installer" > /etc/udev/rules.d/70-persistent-net.rules
623 for dir in /sys/class/net/*; do
624 if [ -e ${dir}/device ]; then
625 dev=$(basename ${dir})
626 mac_address=$(cat /sys/class/net/${dev}/address)
627 echo "ACTION==\"add\", SUBSYSTEM==\"net\", DRIVERS==\"?*\", ATTR{address}==\"${mac_address}\", NAME=\"${dev}\"" >> /etc/udev/rules.d/70-persistent-net.rules
631 # Mark the sysadmin password as expired immediately
634 # Lock the root password
637 # Enable tmpfs mount for /tmp
638 # delete /var/tmp so that it can similinked in
640 systemctl enable tmp.mount
642 # Disable automount of /dev/hugepages
643 systemctl mask dev-hugepages.mount
646 systemctl disable firewalld
649 systemctl disable libvirtd.service
652 systemctl enable rsyncd.service
654 # Allow root to run sudo from a non-tty (for scripts running as root that run sudo cmds)
655 echo 'Defaults:root !requiretty' > /etc/sudoers.d/root
657 # Make fstab just root read/writable
660 # Create first_boot flag
661 touch /etc/platform/.first_boot
665 # Template from: post_kernel_aio_and_worker.cfg
668 # Source common functions
669 . /tmp/ks-functions.sh
671 # Source the generated platform.conf
672 . /etc/platform/platform.conf
674 # Update grub with custom kernel bootargs
675 source /etc/init.d/cpumap_functions.sh
676 n_cpus=$(cat /proc/cpuinfo 2>/dev/null | \
677 awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
678 n_numa=$(ls -d /sys/devices/system/node/node* 2>/dev/null | wc -l)
679 KERN_OPTS=" iommu=pt usbcore.autosuspend=-1"
681 KERN_OPTS="${KERN_OPTS} hugepagesz=2M hugepages=0 default_hugepagesz=2M"
683 # If this is an all-in-one system, we need at least 4 CPUs
684 if [ "$system_type" = "All-in-one" -a ${n_cpus} -lt 4 ]; then
685 report_post_failure_with_msg "ERROR: At least 4 CPUs are required for controller+worker node."
688 # Add kernel options for cpu isolation / affinity
689 if [ ${n_cpus} -gt 1 ]
691 base_cpulist=$(platform_expanded_cpu_list)
692 base_cpumap=$(cpulist_to_cpumap ${base_cpulist} ${n_cpus})
693 avp_cpulist=$(vswitch_expanded_cpu_list)
694 norcu_cpumap=$(invert_cpumap ${base_cpumap} ${n_cpus})
695 norcu_cpulist=$(cpumap_to_cpulist ${norcu_cpumap} ${n_cpus})
697 if [[ "$subfunction" =~ lowlatency ]]; then
698 KERN_OPTS="${KERN_OPTS} isolcpus=${norcu_cpulist}"
699 KERN_OPTS="${KERN_OPTS} nohz_full=${norcu_cpulist}"
701 KERN_OPTS="${KERN_OPTS} isolcpus=${avp_cpulist}"
703 KERN_OPTS="${KERN_OPTS} rcu_nocbs=${norcu_cpulist}"
704 KERN_OPTS="${KERN_OPTS} kthread_cpus=${base_cpulist}"
705 KERN_OPTS="${KERN_OPTS} irqaffinity=${base_cpulist}"
706 # Update vswitch.conf
707 sed -i "s/^VSWITCH_CPU_LIST=.*/VSWITCH_CPU_LIST=\"${avp_cpulist}\"/" /etc/vswitch/vswitch.conf
710 # Add kernel options to ensure an selinux is disabled
711 KERN_OPTS="${KERN_OPTS} selinux=0 enforcing=0"
713 # Add kernel options to set NMI watchdog
714 if [[ "$subfunction" =~ lowlatency ]]; then
715 KERN_OPTS="${KERN_OPTS} nmi_watchdog=0 softlockup_panic=0"
717 KERN_OPTS="${KERN_OPTS} nmi_watchdog=panic,1 softlockup_panic=1"
720 if [[ "$(dmidecode -s system-product-name)" =~ ^ProLiant.*Gen8$ ]]; then
721 KERN_OPTS="${KERN_OPTS} intel_iommu=on,eth_no_rmrr"
723 KERN_OPTS="${KERN_OPTS} intel_iommu=on"
726 # Add kernel option to disable biosdevname if enabled
727 # As this may already be in GRUB_CMDLINE_LINUX, only add if it is not already present
728 grep -q '^GRUB_CMDLINE_LINUX=.*biosdevname=0' /etc/default/grub
729 if [ $? -ne 0 ]; then
730 KERN_OPTS="${KERN_OPTS} biosdevname=0"
733 # Add kernel options to disable kvm-intel.eptad on Broadwell
734 # Broadwell: Model: 79, Model name: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
735 if grep -q -E "^model\s+:\s+79$" /proc/cpuinfo
737 KERN_OPTS="${KERN_OPTS} kvm-intel.eptad=0"
741 #KERN_OPTS="${KERN_OPTS} cgroup_disable=memory"
742 KERN_OPTS="${KERN_OPTS} user_namespace.enable=1"
744 # Add kernel option to avoid jiffies_lock contention on real-time kernel
745 if [[ "$subfunction" =~ lowlatency ]]; then
746 KERN_OPTS="${KERN_OPTS} skew_tick=1"
749 # If the installer asked us to use security related kernel params, use
750 # them in the grub line as well (until they can be configured via puppet)
751 grep -q 'nopti' /proc/cmdline
752 if [ $? -eq 0 ]; then
753 KERN_OPTS="${KERN_OPTS} nopti"
755 grep -q 'nospectre_v2' /proc/cmdline
756 if [ $? -eq 0 ]; then
757 KERN_OPTS="${KERN_OPTS} nospectre_v2"
760 perl -pi -e 's/(GRUB_CMDLINE_LINUX=.*)\"/\1'"$KERN_OPTS"'\"/g' /etc/default/grub
762 if [ -d /sys/firmware/efi ] ; then
763 grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
765 grub2-mkconfig -o /boot/grub2/grub.cfg
771 # Template from: post_lvm_pv_on_rootfs.cfg
774 # Source common functions
775 . /tmp/ks-functions.sh
777 # uncomment the global_filter line in lvm.conf
778 perl -0777 -i.bak -pe 's:(# This configuration option has an automatic default value\.\n)\t# global_filter:$1 global_filter:m' /etc/lvm/lvm.conf
780 # Determine which disk we created our PV on (i.e. the root disk)
781 ROOTDISK=$(get_by_path $(pvdisplay --select 'vg_name=cgts-vg' -C -o pv_name --noheadings))
782 if [ -z "$ROOTDISK" ]; then
783 report_post_failure_with_msg "ERROR: failed to identify rootdisk via pvdisplay"
785 # Edit the LVM config so LVM only looks for LVs on the root disk
786 sed -i "s#^\( *\)global_filter = \[.*#\1global_filter = [ \"a|${ROOTDISK}|\", \"r|.*|\" ]#" /etc/lvm/lvm.conf
790 # Template from: post_net_common.cfg
793 # Source common functions
794 . /tmp/ks-functions.sh
796 http_port=$(get_http_port)
797 echo "repo --name=base --baseurl=http://pxecontroller:${http_port:-8080}/feed/rel-19.12/" > /tmp/repo-include
798 echo "repo --name=updates --baseurl=http://pxecontroller:${http_port:-8080}/updates/rel-19.12/" > /tmp/repo-include
802 # Repository arguments from %pre
803 %include /tmp/repo-include
808 # Source common functions
809 . /tmp/ks-functions.sh
811 # Persist the http port to the platform configuration
812 echo http_port=$(get_http_port) >> /etc/platform/platform.conf
814 # Obtain the boot interface from the PXE boot
815 BOOTIF=`cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=`
816 if [ -d /sys/firmware/efi ] ; then
817 BOOTIF=${BOOTIF#BOOTIF=}
819 BOOTIF=${BOOTIF#BOOTIF=01-}
820 BOOTIF=${BOOTIF//-/:}
825 if [ -n "$BOOTIF" ] ; then
826 ndev=`ip link show |grep -B 1 $BOOTIF |head -1 |awk '{print $2}' |sed -e 's/://'`
827 if [ -n "$ndev" ] ; then
829 # Retrieve the management VLAN from sysinv if it exists
830 mgmt_vlan=`curl -sf http://pxecontroller:6385/v1/isystems/mgmtvlan`
833 report_post_failure_with_msg "ERROR: Unable to communicate with System Inventory REST API. Aborting installation."
836 report_post_failure_with_msg "ERROR: Unable to determine mgmt interface from BOOTIF=$BOOTIF."
839 report_post_failure_with_msg "ERROR: BOOTIF is not set. Unable to determine mgmt interface."
842 if [ $mgmt_vlan -eq 0 ] ; then
844 # Persist the boot device to the platform configuration. This will get
845 # overwritten later if the management_interface is on a bonded interface.
846 echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
848 # Build networking scripts
849 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
854 BROADCAST=127.255.255.255
860 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
870 # Check whether to use inet or inet6
871 ipv6_addr=$(dig +short AAAA controller)
872 if [[ -n "$ipv6_addr" ]]
874 mgmt_address_family=inet6
879 mgmt_address_family=inet
885 # Persist the boot device to the platform configuration. This will get
886 # overwritten later if the management_interface is on a bonded interface.
887 echo management_interface=vlan$mgmt_vlan >> /etc/platform/platform.conf
889 # Build networking scripts
890 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
895 BROADCAST=127.255.255.255
901 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
909 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-vlan$mgmt_vlan
910 DEVICE=vlan$mgmt_vlan
912 DHCLIENTARGS=$dhclientargs
922 # Reject DHCPOFFER from DHCP server that doesn't send
923 # wrs-install-uuid option
924 echo "require wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
925 echo "require dhcp6.wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
927 # Bring up the mgmt vlan so that a dhcp lease is acquired and an address is
928 # setup prior to the post-install reboot. This is so that the timing of the IP
929 # address allocation is similar to how normal/non-pxe installation works.
930 mgmt_iface=vlan$mgmt_vlan
931 dhclient_family=$([[ $mgmt_address_family == "inet" ]] && echo -4 || echo -6)
932 ip link add link $mgmt_dev name $mgmt_iface type vlan id $mgmt_vlan
933 ip link set up dev $mgmt_iface
934 dhclient $dhclient_family $mgmt_iface || true