stx-metal: add kickstart fixes for poky-stx
[pti/rtp.git] / meta-stx / conf / distro / files / ks / controller_ks.cfg
1 #
2 # Copyright (c) 2019 Wind River Systems, Inc.
3 # SPDX-License-Identifier: Apache-2.0
4 #
5
6 %pre
7 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
8 # . /tmp/ks-functions.sh
9 #
10
11 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
12 #
13 # Copyright (c) 2019 Wind River Systems, Inc.
14 #
15 # SPDX-License-Identifier: Apache-2.0
16 #
17
18 function get_by_path()
19 {
20     local disk=\$(cd /dev ; readlink -f \$1)
21     for p in /dev/disk/by-path/*; do
22         if [ "\$disk" = "\$(readlink -f \$p)" ]; then
23             echo \$p
24             return
25         fi
26     done
27 }
28
29 function get_disk()
30 {
31     echo \$(cd /dev ; readlink -f \$1)
32 }
33
34 function report_pre_failure_with_msg()
35 {
36     local msg=\$1
37     echo -e '\n\nInstallation failed.\n'
38     echo "\$msg"
39
40     exit 1
41 }
42
43 function report_post_failure_with_msg()
44 {
45     local msg=\$1
46     cat <<EOF >> /etc/motd
47
48 Installation failed.
49 \$msg
50
51 EOF
52     echo "\$msg" >/etc/platform/installation_failed
53
54     echo -e '\n\nInstallation failed.\n'
55     echo "\$msg"
56
57     exit 1
58 }
59
60 function report_post_failure_with_logfile()
61 {
62     local logfile=\$1
63     cat <<EOF >> /etc/motd
64
65 Installation failed.
66 Please see \$logfile for details of failure
67
68 EOF
69     echo \$logfile >/etc/platform/installation_failed
70
71     echo -e '\n\nInstallation failed.\n'
72     cat \$logfile
73
74     exit 1
75 }
76
77 function get_http_port()
78 {
79     echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
80 }
81
82 END_FUNCTIONS
83
84 %end
85
86 %post
87 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
88 # . /tmp/ks-functions.sh
89 #
90
91 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
92 #
93 # Copyright (c) 2019 Wind River Systems, Inc.
94 #
95 # SPDX-License-Identifier: Apache-2.0
96 #
97
98 function get_by_path()
99 {
100     local disk=\$(cd /dev ; readlink -f \$1)
101     for p in /dev/disk/by-path/*; do
102         if [ "\$disk" = "\$(readlink -f \$p)" ]; then
103             echo \$p
104             return
105         fi
106     done
107 }
108
109 function get_disk()
110 {
111     echo \$(cd /dev ; readlink -f \$1)
112 }
113
114 function report_pre_failure_with_msg()
115 {
116     local msg=\$1
117     echo -e '\n\nInstallation failed.\n'
118     echo "\$msg"
119
120     exit 1
121 }
122
123 function report_post_failure_with_msg()
124 {
125     local msg=\$1
126     cat <<EOF >> /etc/motd
127
128 Installation failed.
129 \$msg
130
131 EOF
132     echo "\$msg" >/etc/platform/installation_failed
133
134     echo -e '\n\nInstallation failed.\n'
135     echo "\$msg"
136
137     exit 1
138 }
139
140 function report_post_failure_with_logfile()
141 {
142     local logfile=\$1
143     cat <<EOF >> /etc/motd
144
145 Installation failed.
146 Please see \$logfile for details of failure
147
148 EOF
149     echo \$logfile >/etc/platform/installation_failed
150
151     echo -e '\n\nInstallation failed.\n'
152     cat \$logfile
153
154     exit 1
155 }
156
157 function get_http_port()
158 {
159     echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
160 }
161
162 END_FUNCTIONS
163
164 %end
165
166
167 # Template from: pre_common_head.cfg
168 %pre --erroronfail
169
170 # Source common functions
171 . /tmp/ks-functions.sh
172
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
176
177 append=
178 if [ -n "$console" ] ; then
179     append="console=$console"
180 fi
181
182 if [ -n "$security_profile" ]; then
183     append="$append security_profile=$security_profile"
184 fi
185
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"
191 else
192     # we need to blacklist the IMA and Integrity Modules
193     # on standard security profile
194     append="$append module_blacklist=integrity,ima"
195     
196     # Disable Kernel auditing in Standard Security Profile mode
197     append="$append audit=0"
198 fi
199
200 if [ -n "$tboot" ]; then
201     append="$append tboot=$tboot"
202 else
203     append="$append tboot=false"
204 fi
205
206 boot_device_arg=
207 if [ -n "$boot_device" ] ; then
208     boot_device_arg="--boot-drive=$(get_by_path $boot_device)"
209 fi
210
211 echo "bootloader --location=mbr $boot_device_arg --timeout=5 --append=\"$append\"" > /tmp/bootloader-include
212
213 echo "timezone --nontp --utc UTC" >/tmp/timezone-include
214 %end
215
216 #version=DEVEL
217 install
218 lang en_US.UTF-8
219 keyboard us
220 %include /tmp/timezone-include
221 # set to 'x' so we can use shadow password
222 rootpw  --iscrypted x
223 selinux --disabled
224 authconfig --enableshadow --passalgo=sha512
225 firewall --service=ssh
226
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
231 zerombr
232
233 # Disk layout from %pre
234 %include /tmp/part-include
235 # Bootloader parms from %pre
236 %include /tmp/bootloader-include
237
238 reboot --eject
239
240
241 # Template from: pre_pkglist.cfg
242 %packages
243 @core
244 @base
245 -kernel-module-igb-uio-rt
246 -kernel-module-wrs-avp-rt
247 -kernel-rt
248 -kernel-rt-kvm
249 -kernel-rt-tools
250 -kernel-rt-tools-libs
251 -kmod-drbd-rt
252 -kmod-e1000e-rt
253 -kmod-i40e-rt
254 -kmod-ixgbe-rt
255 -kmod-tpm-rt
256 -mlnx-ofa_kernel
257 -mlnx-ofa_kernel-rt
258 -mlnx-ofa_kernel-rt-modules
259 -qat16-rt
260 @platform-controller
261 @updates-controller
262 %end
263
264
265 # Template from: pre_disk_setup_common.cfg
266 %pre --erroronfail
267
268 # Source common functions
269 . /tmp/ks-functions.sh
270
271 # This is a really fancy way of finding the first usable disk for the
272 # install and not stomping on the USB device if it comes up first
273
274 # First, parse /proc/cmdline to find the boot args
275 set -- `cat /proc/cmdline`
276 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
277
278 # Find either the ISO or USB device first chopping off partition
279 ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot`
280 sdev=`echo $ISO_DEV | sed -e 's/.$//'`
281 if [ -e /dev/disk/by-label/$sdev ] ; then
282     ISO_DEV=$sdev
283 fi
284 USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot`
285 sdev=`echo $USB_DEV | sed -e 's/.$//'`
286 if [ -e /dev/disk/by-label/$sdev ] ; then
287     USB_DEV=$sdev
288 fi
289
290 # Temporary, until lab pxelinux.cfg files are updated to specify install devices
291 if [ -z "$rootfs_device" -o -z "$boot_device" ]
292 then
293     INST_HDD=""
294     # Prefer a vd* device if this is kvm/qemu
295     for e in vda vdb sda sdb nvme0n1; do
296         if [ -e /dev/$e -a "$ISO_DEV" != "../../$e" -a "$USB_DEV" != "../../$e" ] ; then
297             INST_HDD=$e
298             break
299         fi
300     done
301
302     # Set variables to $INST_HDD if not set
303     rootfs_device=${rootfs_device:-$INST_HDD}
304     boot_device=${boot_device:-$INST_HDD}
305 fi
306
307 # Convert to by-path
308 orig_rootfs_device=$rootfs_device
309 rootfs_device=$(get_by_path $rootfs_device)
310
311 orig_boot_device=$boot_device
312 boot_device=$(get_by_path $boot_device)
313
314 if [ ! -e "$rootfs_device" -o ! -e "$boot_device" ] ; then
315     # Touch this file to prevent Anaconda from dying an ungraceful death
316     touch /tmp/part-include
317
318     report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is invalid."
319 fi
320
321 # Ensure specified device is not a USB drive
322 udevadm info --query=property --name=$rootfs_device |grep -q '^ID_BUS=usb' || \
323     udevadm info --query=property --name=$boot_device |grep -q '^ID_BUS=usb'
324 if [ $? -eq 0 ]; then
325     # Touch this file to prevent Anaconda from dying an ungraceful death
326     touch /tmp/part-include
327
328     report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is a USB drive."
329 fi
330
331 # Deactivate existing volume groups to avoid Anaconda issues with pre-existing groups
332 vgs --noheadings -o vg_name | xargs --no-run-if-empty -n 1 vgchange -an
333
334 # Remove volumes and group for cgts-vg, if any
335 lvremove --force cgts-vg
336 pvs --select 'vg_name=cgts-vg' --noheadings -o pv_name | xargs --no-run-if-empty pvremove --force --force --yes
337 vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
338
339 ONLYUSE_HDD=""
340 if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
341     # In an upgrade, only wipe the disk with the rootfs and boot partition
342     echo "In upgrade, wiping only $rootfs_device"
343     WIPE_HDD="$(get_disk $rootfs_device)"
344     ONLYUSE_HDD="$(basename $(get_disk $rootfs_device))"
345     if [ "$(get_disk $rootfs_device)" != "$(get_disk $boot_device)" ]; then
346         WIPE_HDD="$WIPE_HDD,$(get_disk $boot_device)"
347         ONLYUSE_HDD="$ONLYUSE_HDD,$(basename $(get_disk $boot_device))"
348     fi
349 else
350     # Make a list of all the hard drives that are to be wiped
351     WIPE_HDD=""
352     # Partition type OSD has a unique globally identifier
353     part_type_guid_str="Partition GUID code"
354     CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
355
356     # Check if we wipe OSDs
357     if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
358         echo "Wipe OSD data."
359         WIPE_CEPH_OSDS="true"
360     else
361         echo "Skip Ceph OSD data wipe."
362         WIPE_CEPH_OSDS="false"
363     fi
364
365     for f in /dev/disk/by-path/*
366     do
367         dev=$(readlink -f $f)
368         lsblk --nodeps --pairs $dev | grep -q 'TYPE="disk"'
369         if [ $? -ne 0 ]
370         then
371             continue
372         fi
373
374         # Avoid wiping USB drives
375         udevadm info --query=property --name=$dev |grep -q '^ID_BUS=usb' && continue
376
377         # Avoid wiping ceph osds if sysinv tells us so
378         if [ ${WIPE_CEPH_OSDS} == "false" ]; then
379             wipe_dev="true"
380             part_numbers=( `parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
381             # Scanning the partitions looking for CEPH OSDs and
382             # skipping any disk found with such partitions
383             for part_number in "${part_numbers[@]}"; do
384                 sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
385                 part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
386                 if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
387                     echo "OSD found on $dev, skipping wipe"
388                     wipe_dev="false"
389                     break
390                 fi
391             done
392             if [ "$wipe_dev" == "false" ]; then
393                 continue
394             fi
395         fi
396
397         # Add device to the wipe list
398         devname=$(basename $dev)
399         if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ]; then
400             if [ -n "$WIPE_HDD" ]; then
401                 WIPE_HDD=$WIPE_HDD,$dev
402             else
403                 WIPE_HDD=$dev
404             fi
405         fi
406     done
407     echo "Not in upgrade, wiping disks: $WIPE_HDD"
408 fi
409
410 for dev in ${WIPE_HDD//,/ }
411 do
412     # Clearing previous GPT tables or LVM data
413     # Delete the first few bytes at the start and end of the partition. This is required with
414     # GPT partitions, they save partition info at the start and the end of the block.
415     # Do this for each partition on the disk, as well.
416     partitions=$(lsblk -rip $dev -o TYPE,NAME |awk '$1 == "part" {print $2}')
417     for p in $partitions $dev
418     do
419         echo "Pre-wiping $p from kickstart"
420         dd if=/dev/zero of=$p bs=512 count=34
421         dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
422     done
423 done
424
425 # Check for remaining cgts-vg PVs, which could potentially happen
426 # in an upgrade where we're not wiping all disks.
427 # If we ever create other volume groups from kickstart in the future,
428 # include them in this search as well.
429 partitions=$(pvs --select 'vg_name=cgts-vg' -o pv_name --noheading | grep -v '\[unknown\]')
430 for p in $partitions
431 do
432     echo "Pre-wiping $p from kickstart (cgts-vg present)"
433     dd if=/dev/zero of=$p bs=512 count=34
434     dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
435 done
436
437 let -i gb=1024*1024*1024
438
439 cat<<EOF>/tmp/part-include
440 clearpart --all --drives=$WIPE_HDD --initlabel
441 EOF
442
443 if [ -n "$ONLYUSE_HDD" ]; then
444     cat<<EOF>>/tmp/part-include
445 ignoredisk --only-use=$ONLYUSE_HDD
446 EOF
447 fi
448
449 if [ -d /sys/firmware/efi ] ; then
450     cat<<EOF>>/tmp/part-include
451 part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
452 EOF
453 else
454     cat<<EOF>>/tmp/part-include
455 part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
456 EOF
457 fi
458
459
460 # Template from: pre_disk_controller.cfg
461
462 ## NOTE: updates to partition sizes need to be also reflected in
463 ## _controller_filesystem_limits() in sysinv/api/controllers/v1/istorconfig.py
464
465 ROOTFS_SIZE=20000
466 LOG_VOL_SIZE=8000
467 SCRATCH_VOL_SIZE=8000
468
469 ROOTFS_OPTIONS="defaults"
470 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
471 if [ -n "$profile_mode" ]; then
472    # Enable iversion labelling for rootfs when IMA is enabled
473    ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
474 fi
475
476 cat<<EOF>>/tmp/part-include
477 part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
478 part pv.253004 --grow --asprimary --size=500 --ondrive=$(get_disk $rootfs_device)
479 volgroup cgts-vg --pesize=32768 pv.253004
480 logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
481 logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
482 part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
483
484 EOF
485
486 %end
487
488
489 # Template from: post_platform_conf_controller.cfg
490 %post --erroronfail
491
492 # Source common functions
493 . /tmp/ks-functions.sh
494
495 # Set the security profile mode
496 secprofile="standard"
497 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
498 if [ -n "$profile_mode" ]; then
499    secprofile="extended"
500 fi
501
502 mkdir -p -m 0775 /etc/platform
503 cat <<EOF > /etc/platform/platform.conf
504 nodetype=controller
505 subfunction=controller
506 system_type=Standard
507 security_profile=$secprofile
508 EOF
509
510 %end
511
512
513 # Template from: post_common.cfg
514 %post --erroronfail
515
516 # Source common functions
517 . /tmp/ks-functions.sh
518
519 # Turn off locale support for i18n if is not installed
520 if [ ! -d /usr/share/i18n ] ; then
521    rm -f /etc/sysconfig/i18n
522 fi
523 # Unset the hostname
524 rm /etc/hostname
525
526 # If using a serial install make sure to add a getty on the tty1
527 conarg=`cat /proc/cmdline |xargs -n1 echo |grep console= |grep ttyS`
528 if [ -n "$conarg" ] ; then
529    echo "1:2345:respawn:/sbin/mingetty tty1" >> /etc/inittab
530 fi
531
532 #### SECURITY PROFILE HANDLING (Post Installation) ####
533 # Check if the Security profile mode is enabled
534 # and load the appropriate kernel modules
535 secprofile=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
536 if [ -n "$secprofile" ]; then
537    echo "In Extended Security profile mode. Loading IMA kernel module"
538    systemctl enable auditd.service
539    # Add the securityfs mount for the IMA Runtime measurement list
540    echo "securityfs     /sys/kernel/security    securityfs    defaults,nodev 0 0" >> /etc/fstab
541 else
542    # Disable audit daemon in the Standard Security Profile
543    systemctl disable auditd
544 fi
545
546 . /etc/platform/platform.conf
547 # Configure smart package manager channels
548 rm -rf /var/lib/smart
549 mkdir /var/lib/smart
550 /usr/bin/smart channel -y \
551     --add rpmdb type=rpm-sys name="RPM Database"
552 /usr/bin/smart channel -y \
553     --add base type=rpm-md name="Base" baseurl=http://controller:${http_port:-8080}/feed/rel-19.12
554 /usr/bin/smart channel -y \
555     --add updates type=rpm-md name="Patches" baseurl=http://controller:${http_port:-8080}/updates/rel-19.12
556
557 # Configure smart to use rpm --nolinktos option
558 /usr/bin/smart config --set rpm-nolinktos=true
559
560 # Configure smart to use rpm --nosignature option
561 /usr/bin/smart config --set rpm-check-signatures=false
562
563 # Delete the CentOS yum repo files
564 rm -f /etc/yum.repos.d/CentOS-*
565
566 # Persist the boot device naming as UDEV rules so that if the network device
567 # order changes post-install that we will still be able to DHCP from the
568 # correct interface to reach the active controller.  For most nodes only the
569 # management/boot interface needs to be persisted but because we require both
570 # controllers to be identically configured and controller-0 and controller-1
571 # are installed differently (e.g., controller-0 from USB and controller-1 from
572 # network) it is not possible to know which interface to persist for
573 # controller-0.  The simplest solution is to persist all interfaces.
574 #
575 mkdir -p /etc/udev/rules.d
576 echo "# Persisted network interfaces from anaconda installer" > /etc/udev/rules.d/70-persistent-net.rules
577 for dir in /sys/class/net/*; do
578     if [ -e ${dir}/device ]; then
579        dev=$(basename ${dir})
580        mac_address=$(cat /sys/class/net/${dev}/address)
581        echo "ACTION==\"add\", SUBSYSTEM==\"net\", DRIVERS==\"?*\", ATTR{address}==\"${mac_address}\", NAME=\"${dev}\"" >> /etc/udev/rules.d/70-persistent-net.rules
582     fi
583 done
584
585 # Mark the sysadmin password as expired immediately
586 chage -d 0 sysadmin
587
588 # Lock the root password
589 passwd -l root
590
591 # Enable tmpfs mount for /tmp
592 # delete /var/tmp so that it can similinked in
593 rm -rf /var/tmp
594 systemctl enable tmp.mount
595
596 # Disable automount of /dev/hugepages
597 systemctl mask dev-hugepages.mount
598
599 # Disable firewall
600 systemctl disable firewalld
601
602 # Disable libvirtd
603 systemctl disable libvirtd.service
604
605 # Enable rsyncd
606 systemctl enable rsyncd.service
607
608 # Allow root to run sudo from a non-tty (for scripts running as root that run sudo cmds)
609 echo 'Defaults:root !requiretty' > /etc/sudoers.d/root
610
611 # Make fstab just root read/writable
612 chmod 600 /etc/fstab
613
614 # Create first_boot flag
615 touch /etc/platform/.first_boot
616
617 %end
618
619 # Template from: post_kernel_controller.cfg
620 %post --erroronfail
621
622 # Source common functions
623 . /tmp/ks-functions.sh
624
625 ## Custom kernel options
626 KERN_OPTS=" intel_iommu=off usbcore.autosuspend=-1"
627
628 ## Setup the loop module to support up to 15 partitions so that we can enable the
629 ## customer to manually resize images if needed.
630 ##
631 KERN_OPTS="${KERN_OPTS} loop.max_part=15"
632
633 ## Add kernel options to ensure an selinux is disabled
634 KERN_OPTS="${KERN_OPTS} selinux=0 enforcing=0"
635
636 # Add kernel options to ensure NMI watchdog is enabled, if supported
637 KERN_OPTS="${KERN_OPTS} nmi_watchdog=panic,1 softlockup_panic=1"
638
639 # Add kernel option to disable biosdevname if enabled
640 # As this may already be in GRUB_CMDLINE_LINUX, only add if it is not already present
641 grep -q '^GRUB_CMDLINE_LINUX=.*biosdevname=0' /etc/default/grub
642 if [ $? -ne 0 ]; then
643     KERN_OPTS="${KERN_OPTS} biosdevname=0"
644 fi
645
646 # k8s updates
647 #KERN_OPTS="${KERN_OPTS} cgroup_disable=memory"
648 KERN_OPTS="${KERN_OPTS} user_namespace.enable=1"
649
650 # If the installer asked us to use security related kernel params, use
651 # them in the grub line as well (until they can be configured via puppet)
652 grep -q 'nopti' /proc/cmdline
653 if [ $? -eq 0 ]; then
654     KERN_OPTS="${KERN_OPTS} nopti"
655 fi
656 grep -q 'nospectre_v2' /proc/cmdline
657 if [ $? -eq 0 ]; then
658     KERN_OPTS="${KERN_OPTS} nospectre_v2"
659 fi
660
661 perl -pi -e 's/(GRUB_CMDLINE_LINUX=.*)\"/\1'"$KERN_OPTS"'\"/g' /etc/default/grub
662
663 if [ -d /sys/firmware/efi ] ; then
664   grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
665 else
666   grub2-mkconfig -o /boot/grub2/grub.cfg
667 fi
668
669 %end
670
671
672 # Template from: post_lvm_pv_on_rootfs.cfg
673 %post --erroronfail
674
675 # Source common functions
676 . /tmp/ks-functions.sh
677
678 # uncomment the global_filter line in lvm.conf
679 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
680
681 # Determine which disk we created our PV on (i.e. the root disk)
682 ROOTDISK=$(get_by_path $(pvdisplay --select 'vg_name=cgts-vg' -C -o pv_name --noheadings))
683 if [ -z "$ROOTDISK" ]; then
684     report_post_failure_with_msg "ERROR: failed to identify rootdisk via pvdisplay"
685 fi
686 # Edit the LVM config so LVM only looks for LVs on the root disk
687 sed -i "s#^\( *\)global_filter = \[.*#\1global_filter = [ \"a|${ROOTDISK}|\", \"r|.*|\" ]#" /etc/lvm/lvm.conf
688 %end
689
690
691 # Template from: post_usb_controller.cfg
692 %pre --erroronfail
693
694 # Source common functions
695 . /tmp/ks-functions.sh
696
697 if [ -d /mnt/install/source ]; then
698     srcdir=/mnt/install/source
699 else
700     srcdir=/run/install/repo
701 fi
702
703 touch /tmp/repo-include
704
705 if [ -d ${srcdir}/patches ]; then
706     echo "repo --name=updates --baseurl=file://${srcdir}/patches/" > /tmp/repo-include
707 fi
708
709 %end
710
711 # Repository arguments from %pre
712 %include /tmp/repo-include
713
714 %post --erroronfail
715
716 # Source common functions
717 . /tmp/ks-functions.sh
718
719 mgmt_dev=none
720
721 # Persist the boot device to the platform configuration. This will get
722 # overwritten when config_controller is run.
723 echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
724
725 # persist the default http port number to platform configuration. This
726 # will get overwritten when config_controller is run.
727 echo http_port=8080 >> /etc/platform/platform.conf
728
729 # Build networking scripts
730 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
731 DEVICE=lo
732 IPADDR=127.0.0.1
733 NETMASK=255.0.0.0
734 NETWORK=127.0.0.0
735 BROADCAST=127.255.255.255
736 ONBOOT=yes
737 IPV6_AUTOCONF=no
738 NAME=loopback
739 EOF
740
741 %end
742
743
744 # Note, this section is different and replaced with a wget
745 # if doing the initial install off the network
746 %post --nochroot
747 if [ -d /mnt/install/source ]; then
748     srcdir=/mnt/install/source
749 else
750     srcdir=/run/install/repo
751 fi
752
753 if [ -d $srcdir/Packages ] ; then
754     mkdir -p /mnt/sysimage/www/pages/feed/rel-19.12
755     cp -r $srcdir/Packages /mnt/sysimage/www/pages/feed/rel-19.12/Packages
756     cp -r $srcdir/repodata /mnt/sysimage/www/pages/feed/rel-19.12/repodata
757     cp $srcdir/*.cfg /mnt/sysimage/www/pages/feed/rel-19.12
758 fi
759
760 if [ -d $srcdir/patches ]; then
761     mkdir -p /mnt/sysimage/www/pages/updates/rel-19.12
762     cp -r $srcdir/patches/Packages /mnt/sysimage/www/pages/updates/rel-19.12/Packages
763     cp -r $srcdir/patches/repodata /mnt/sysimage/www/pages/updates/rel-19.12/repodata
764     mkdir -p /mnt/sysimage/opt/patching
765     cp -r $srcdir/patches/metadata /mnt/sysimage/opt/patching/metadata
766     mkdir -p /mnt/sysimage/opt/patching/packages/19.12
767     
768     find /mnt/sysimage/www/pages/updates/rel-19.12/Packages -name '*.rpm' \
769         | xargs --no-run-if-empty -I files cp --preserve=all files /mnt/sysimage/opt/patching/packages/19.12/
770 fi
771
772 # Create a uuid specific to this installation
773 INSTALL_UUID=`uuidgen`
774 echo $INSTALL_UUID > /mnt/sysimage/www/pages/feed/rel-19.12/install_uuid
775 echo "INSTALL_UUID=$INSTALL_UUID" >> /mnt/sysimage/etc/platform/platform.conf
776 %end
777
778 %post
779
780 # This is a USB install, so set ONBOOT=yes for network devices.
781 # Doing this in the %post so we don't unintentionally setup a
782 # network device during the installation.
783 for f in /etc/sysconfig/network-scripts/ifcfg-*; do
784     if grep -q '^ONBOOT=' ${f}; then
785         sed -i 's/^ONBOOT=.*/ONBOOT=yes/' ${f}
786     else
787         echo "ONBOOT=yes" >> ${f}
788     fi
789     if grep -q '^IPV6_AUTOCONF=' ${f}; then
790         sed -i 's/^IPV6_AUTOCONF=.*/IPV6_AUTOCONF=no/' ${f}
791     else
792         echo "IPV6_AUTOCONF=no" >> ${f}
793     fi
794 done
795
796 %end
797
798
799 # Template from: post_usb_addon.cfg
800 %pre --erroronfail
801 if [ -d /mnt/install/source ]; then
802     srcdir=/mnt/install/source
803 else
804     srcdir=/run/install/repo
805 fi
806
807 if [ -f ${srcdir}/ks-addon.cfg ]; then
808     cp ${srcdir}/ks-addon.cfg /tmp/
809 else
810     cat <<EOF > /tmp/ks-addon.cfg
811 # No custom addon included
812 EOF
813 fi
814 %end
815
816 %post --nochroot
817 if [ -d /mnt/install/source ]; then
818     srcdir=/mnt/install/source
819 else
820     srcdir=/run/install/repo
821 fi
822
823 # Store the ks-addon.cfg for debugging
824 mkdir -p /mnt/sysimage/var/log/anaconda
825 cp /tmp/ks-addon.cfg /mnt/sysimage/var/log/anaconda/
826 %end
827
828 %post --erroronfail
829
830 # Source common functions
831 . /tmp/ks-functions.sh
832
833 %include /tmp/ks-addon.cfg
834
835 %end