# Kickstart file for foundations # Branch on argument RHT_ENROLLMENT=# # #= 0 - foundation0 for instructor # #= X - foundationX for students # #=EXAM - exam server for instructor (without content) install authconfig --enableshadow --passalgo=sha512 firewall --disabled selinux --enforcing services --disabled=kdump,network # Provide disk, lang, keyboard, timezone, rootpw, user (from %pre) %include /tmp/rht-ksconfig %packages @base @core @gnome-desktop @internet-browser @x11 @fonts @input-methods # pick up other base and language from %pre %include /tmp/rht-packages %end # ---------------------------------------------------------------- # pre script # goals: # + display /proc/cmdline in log # + identify enrollment/station and some variables across scripts # + test/abort mismatch of install media (wrong RHCIfoundation) # + add appropriate commands (rootpw, etc) # + generate all partitioning lines which allocate disk space # + add appropriate network lines # + set/download default keyboard, language, and/or timezone # + add appropriate packages # ---------------------------------------------------------------- %pre ( set -x chvt 8 echo "$(date): Beginning pre script..." | tee /dev/tty8 # ---------------------------------------------------------------- # display /proc/cmdline in log # ---------------------------------------------------------------- echo "The /proc/cmdline...." | tee /dev/tty8 cat /proc/cmdline | tee /dev/tty8 # ---------------------------------------------------------------- # if requested, list manifests, wait, and abort # ---------------------------------------------------------------- if (egrep -i '\' /proc/cmdline); then chvt 1 echo | tee /dev/tty1 echo -e "The requested list of manifests on the USB:\r" | tee /dev/tty1 echo | tee /dev/tty1 for icmfname in $(ls /run/install/isodir/manifests/*.icmf); do partname=$(echo ${icmfname} | sed 's|.*/||') echo -e "${partname} \r" | tee /dev/tty1 done # */ for colors in vim from the previous line echo -n "Press to reboot..." > /dev/tty1 read text reboot fi # ---------------------------------------------------------------- # identify enrollment/station and some variables across scripts # ---------------------------------------------------------------- echo "Identifying enrollment/station and variables...." | tee /dev/tty8 echo "RHT_VENUE=ilt" > /tmp/rht cat /proc/cmdline | grep -o "RHT_ENROLLMENT=[0-9]*" >> /tmp/rht ROLE="foundation" if (egrep -i '\.*/\L\1/i' /proc/cmdline) fi echo "RHT_ROLE=${ROLE}" >> /tmp/rht COURSETECH="" COURSE="" COURSECMD=$(egrep -io '\<(rh[ds]?|jb|cl|ceph|do|es)[0-9]{1,3}[^ ]*\>' /proc/cmdline) RAVCMD=$(egrep -io '\' /proc/cmdline) if [[ -n "${COURSECMD}" ]]; then COURSETECH=${COURSECMD,,} COURSE=${COURSETECH%-*} # Verify course is on the USB if ! $( ls /run/install/isodir/manifests/${COURSETECH^^}-*.icmf &>/dev/null ) ; then echo "Invalid course ${COURSETECH} specified" | tee /dev/tty8 COURSETECH="" COURSE="" fi fi echo "RHT_COURSE=${COURSE}" >> /tmp/rht echo "RHT_TITLE=" >> /tmp/rht echo "RHT_VMS=" >> /tmp/rht source /tmp/rht # Define ZERO [[ ${RHT_ENROLLMENT} -eq 0 ]] && ZERO=0 [[ $((RHT_ENROLLMENT/512)) -eq 1 ]] && ZERO=$((RHT_ENROLLMENT%512)) [[ -n "${ZERO}" ]] && echo -e "RHT_MAXSTATIONS=20\nRHT_VM0=\nRHT_GVMS=" >> /tmp/rht echo "RHT_PRIVUSEOVS=" >> /tmp/rht echo "RHT_NOSTARTVMS=" >> /tmp/rht echo "RHT_NOFINISHVMS=" >> /tmp/rht RHTINST_MOUNT=/content RHEL_RELEASE=rhel7.4 RHELH_TREE=${RHEL_RELEASE}/x86_64 cat > /tmp/rht-ksvars <<-EOF COURSETECH=${COURSETECH} COURSE=${COURSE} RAVCMD=${RAVCMD} RHTINST_MOUNT=${RHTINST_MOUNT} RHEL_RELEASE=${RHEL_RELEASE} RHELH_TREE=${RHELH_TREE} UCF_RELEASE=5.r2017111415gitdd10090 ZERO=${ZERO} EXAM=256 EXAM_REPO_PATH=/var/ftp/pub/RHEL/7.4/x86_64 EOF echo "RHT_VMTREE=${RHELH_TREE}" >> /tmp/rht if (egrep -i 'LABEL=RHTINST' /proc/cmdline); then echo "RHT_INSTALLSOURCE=cdrom" >> /tmp/rht-ksvars else echo "RHT_INSTALLSOURCE=pxe" >> /tmp/rht-ksvars fi source /tmp/rht-ksvars touch /tmp/rht-ksconfig touch /tmp/rht-packages # ---------------------------------------------------------------- # test/abort mismatch of install media (wrong RHCIfoundation) # ---------------------------------------------------------------- if [[ "${RHT_INSTALLSOURCE}" == "cdrom" ]]; then #redhat_release=$(sed -e 's/.*release //' -e 's/ .*//' /etc/redhat-release) rhelnodot=${RHEL_RELEASE//.} ucfrel=${UCF_RELEASE//.r*} if ! $( ls /run/install/isodir/manifests/RHCIfoundation-${rhelnodot^^}-${ucfrel}.*.icmf &>/dev/null ) ; then # Abort, abort chvt 1 echo | tee /dev/tty1 echo -e "RHCIfoundation-${rhelnodot^^}-${ucfrel} not found on USB\r" | tee /dev/tty1 echo -e "Boot media (${RHEL_RELEASE}) must match USB\r" | tee /dev/tty1 echo -n "Press to reboot..." > /dev/tty1 read text reboot fi fi # ---------------------------------------------------------------- # add appropriate commands (rootpw, etc) # ---------------------------------------------------------------- echo "Adding commands to instruction list..." | tee /dev/tty8 # Temporary workaround for RHEL 7.3 beta regression # https://bugzilla.redhat.com/show_bug.cgi?id=1375462 #if [[ "${RHEL_RELEASE}" == "rhel7.3" ]]; then # cat >> /tmp/rht-ksconfig <<-EOF # selinux --permissive # EOF #else # cat >> /tmp/rht-ksconfig <<-EOF # selinux --enforcing # EOF #fi if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then cat >> /tmp/rht-ksconfig <<-EOF rootpw --iscrypted \$6\$oZ1JGQiQ\$0lau6DEHSV81iQ54SJyjhI7s9DvAz2Ly5JVwGxMXJqDodk61DXZnF79ibX.scEeHKIe1tBTqLSCIfYV2k3AuW1 user --name=kiosk --password=redhat --plaintext firewall --enabled EOF if [[ -z "${ZERO}" ]]; then echo "Adding reboot to instruction list..." | tee /dev/tty8 cat >> /tmp/rht-ksconfig <<-EOF reboot EOF elif [[ -n "${RAVCMD}" ]]; then echo "Adding poweroff to instruction list..." | tee /dev/tty8 cat >> /tmp/rht-ksconfig <<-EOF poweroff EOF fi else cat >> /tmp/rht-ksconfig <<-EOF firewall --disabled text rootpw --plaintext redhat cmdline eula --agreed user --name=candidate xconfig --startxonboot firstboot --disabled EOF fi # ---------------------------------------------------------------- # generate all partitioning lines which allocate disk space # ---------------------------------------------------------------- # the primary disk is where all of the physical allocations take place. # if we are not careful, Anaconda might allocate partitions on the # instructor USB drive. You would like to think we could just say # "ignoredisk ", but then Anaconda will not read the # installer off of it. # CANDIDATES = physical disks (disks that do not end in a number) # Going to need to be more careful here with CANDIDATES: # Drop dm-*, loop*. # I do not think partitions are going to be here by default # Do I still care if it is removable (classroom-on-a-stick) # New PCIe-NVMe disks are named: /dev/nvme0n1 (with p1 added) # CANDIDATES = devices of TYPE disk (avoiding the skipping of partitions, etc) # SRCDISK = disk that contains the LABEL='RHTINST' partition # MAINDISK = calculated main disk #CANDIDATES=$(ls /sys/block | grep -v "[0-9]$") #CANDIDATES=$(ls /sys/block | grep -Ev '^(dm-|loop)') #CANDIDATES=$(lsblk -ido KNAME,TYPE | grep -w disk | cut -d" " -f1) CANDIDATES=$(lsblk -ido KNAME,TYPE | grep -w disk | cut -d" " -f1 | grep -Ev '^fd') SRCDISK=$(blkid -t LABEL=RHTINST | sed -e 's:^/dev/::' -e 's/[0-9].*//') for d in $CANDIDATES; do #grep -q 1 /sys/block/$d/removable && continue [[ "$d" == "$SRCDISK" ]] && continue MAINDISK=$d break done echo "RHT: Using $MAINDISK as primary disk" | tee /dev/tty8 echo "RHT: Using $SRCDISK as source disk" | tee /dev/tty8 echo "MAINDISK=$MAINDISK" >> /tmp/rht-ksvars if [[ -z "${MAINDISK}" ]]; then # Abort, abort chvt 1 echo | tee /dev/tty1 echo -e "Could not find a disk to install to\r" | tee /dev/tty1 echo -n "Press to reboot..." > /dev/tty1 read text reboot fi if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then cat >> /tmp/rht-ksconfig <<-EOF bootloader --location=mbr --boot-drive=$MAINDISK --password=grub.pbkdf2.sha512.10000.10C92AB839B801A4D8D6EE380C44E527C8D20D7A9C915BDDD8AB39EDBF76D183C98ACE6E967A5FF78C33EDAF2CEEC55E46D2253FC1EDD2AE240F9262B0D25BA2.9C4624BFDD38FE34704588F79AE73E30C5555FD1CE920C5F3CBF8F3C4B3C443CF889242462BC03C6F6795DBC8E5E43FD0D260E3D6F5AC32269455EC452A4A9A4 --iscrypted EOF else cat >> /tmp/rht-ksconfig <<-EOF bootloader --location=mbr --boot-drive=$MAINDISK EOF fi cat >> /tmp/rht-ksconfig <<-EOF clearpart --all --drives=$MAINDISK zerombr part / --fstype=xfs --size=80000 --asprimary --grow --fsoptions="nobarrier" --ondisk $MAINDISK part swap --recommended --ondisk $MAINDISK EOF # ---------------------------------------------------------------- # add appropriate network lines # ---------------------------------------------------------------- echo "Adding network lines to instruction list..." | tee /dev/tty8 [[ -z "${ZERO}" ]] && N=${RHT_ENROLLMENT} || N=250 # For some more troubleshooting of following NICs ip a | grep '^[[:digit:]]' NICLIST="$(ip a | grep '^[[:digit:]]' | cut -d: -f2)" NIC1= NIC2= for nic in ${NICLIST} ; do # Skip if loopback [[ "${nic}" == "lo" ]] && continue # Skip if not in /sys/class/net [[ ! -d /sys/class/net/${nic} ]] && continue # Skip if wireless [[ -d /sys/class/net/${nic}/wireless ]] && continue grep 'DEVTYPE=wlan' /sys/class/net/${nic}/uevent &>/dev/null && continue # Skip if WWAN grep 'DEVTYPE=wwan' /sys/class/net/${nic}/uevent &>/dev/null && continue # Assess whether this NIC is up if grep 'up' /sys/class/net/${nic}/operstate &>/dev/null ; then # If NIC1 is already occupied, is it up? if [[ -n "${NIC1}" ]]; then if grep 'up' /sys/class/net/${NIC1}/operstate &>/dev/null ; then NIC2=${nic} else NIC2=${NIC1} NIC1=${nic} fi else NIC1=${nic} fi else # If NIC1 is already occupied, put it second if [[ -n "${NIC1}" ]]; then NIC2=${nic} else NIC1=${nic} fi fi # If we already have two NICs, break out [[ -n "${NIC2}" ]] && break done # Try to follow the first UP interface unless both are DOWN #if (ip a | grep -q '^2:.*:.*state UP') ; then # NIC1=$(ip a | sed -n -e '/^2:.*:/s/2:[ \t]*\(.*\):.*/\1/p') # NIC2=$(ip a | sed -n -e '/^3:.*:/s/3:[ \t]*\(.*\):.*/\1/p') #elif (ip a | grep -q '^3:.*:.*state UP') ; then # NIC1=$(ip a | sed -n -e '/^3:.*:/s/3:[ \t]*\(.*\):.*/\1/p') # NIC2=$(ip a | sed -n -e '/^2:.*:/s/2:[ \t]*\(.*\):.*/\1/p') #else # NIC1=$(ip a | sed -n -e '/^2:.*:/s/2:[ \t]*\(.*\):.*/\1/p') # NIC2=$(ip a | sed -n -e '/^3:.*:/s/3:[ \t]*\(.*\):.*/\1/p') #fi #NIC1=$(ip a | sed -n -e '/^[23]:.*:.*state UP/s/.:[ \t]*\(.*\):.*/\1/p') #NIC2=$(ip a | sed -n -e '/^[23]:.*:.*state DOWN/s/.:[ \t]*\(.*\):.*/\1/p') echo NICLIST=\"${NICLIST}\" >> /tmp/rht-ksvars echo NIC1=\"${NIC1}\" >> /tmp/rht-ksvars echo NIC2=\"${NIC2}\" >> /tmp/rht-ksvars NICACTIVATE="" && [[ "${RHT_INSTALLSOURCE}" = "cdrom" ]] && NICACTIVATE="--activate" if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then if [[ -n "${ZERO}" ]]; then cat >> /tmp/rht-ksconfig <<-EOF network --bootproto=static --ip=172.25.254.${N} --netmask=255.255.255.0 --gateway=172.25.254.254 --nameserver=172.25.254.250 --device=${NIC1} --hostname=foundation0.ilt.example.com ${NICACTIVATE} EOF else cat >> /tmp/rht-ksconfig <<-EOF network --bootproto=static --ip=172.25.254.${N} --netmask=255.255.255.0 --gateway=172.25.254.254 --nameserver=172.25.254.250 --device=${NIC1} --hostname=foundation${RHT_ENROLLMENT}.ilt.example.com ${NICACTIVATE} EOF fi else cat >> /tmp/rht-ksconfig <<-EOF network --bootproto=dhcp --hostname=localhost.localdomain EOF fi if [[ -n "$NIC2" ]]; then cat >> /tmp/rht-ksconfig <<-EOF network --bootproto=dhcp --device=${NIC2} --onboot=no EOF fi # ---------------------------------------------------------------- # set/download default keyboard, language, and/or timezone # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then echo "Setting default keyboard and lang on foundation0..." | tee /dev/tty8 # These lines have to be tab indented to avoid later processing of # /root/anaconda-ks.cfg to extract keyboard and lang cat >> /tmp/rht-ksconfig <<-EOF keyboard --vckeymap=us --xlayouts='us' lang en_US.UTF-8 EOF if [[ -n "${RAVCMD}" ]]; then cat >> /tmp/rht-ksconfig <<-EOF timezone Etc/UTC --isUtc EOF fi if [[ -f /run/install/isodir/boot/ks/rht-locale-packages ]]; then cat /run/install/isodir/boot/ks/rht-locale-packages >> /tmp/rht-packages fi elif [[ ${RHT_ENROLLMENT} -eq ${EXAM} ]]; then echo "Setting default keyboard, lang, and timezone on exam server..." | tee /dev/tty8 # These lines have to be tab indented to avoid later processing of # /root/anaconda-ks.cfg to extract keyboard and lang cat >> /tmp/rht-ksconfig <<-EOF timezone Etc/UTC --isUtc keyboard --vckeymap=us --xlayouts='us' lang en_US.UTF-8 EOF else echo "Downloading keyboard, lang, and timezone on foundationX..." | tee /dev/tty8 wget -O /tmp/rht-locale http://172.25.254.250/ks/rht-locale | tee /dev/tty8 if $(grep keyboard /tmp/rht-locale &>/dev/null) ; then cat /tmp/rht-locale >> /tmp/rht-ksconfig fi wget -O /tmp/rht-locale-packages http://172.25.254.250/ks/rht-locale-packages | tee /dev/tty8 cat /tmp/rht-locale-packages >> /tmp/rht-packages fi # ---------------------------------------------------------------- # add appropriate packages # ---------------------------------------------------------------- if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then echo "Adding base packages to package list..." | tee /dev/tty8 cat >> /tmp/rht-packages <<-EOF @console-internet @java-platform @network-file-system-client @perl-runtime @virtualization-client @virtualization-hypervisor @virtualization-platform @virtualization-tools mtools pax EOF if [[ -n "${ZERO}" ]]; then echo "Adding foundation0 packages to package list..." | tee /dev/tty8 cat >> /tmp/rht-packages <<-EOF createrepo PyYAML EOF fi else echo "Adding exam server packages to package list..." | tee /dev/tty8 cat >> /tmp/rht-packages <<-EOF @desktop-debugging @dial-up @guest-agents @guest-desktop-agents @multimedia @print-client virt-install virt-manager virt-viewer virt-top httpd vsftpd bind bind-chroot perl-CGI perl-XML-Parser perl-XML-Twig perl-DBD-SQLite perl-Time-HiRes expect dialog rpm-build ntp syslinux system-config-keyboard -gnome-initial-setup EOF fi # ---------------------------------------------------------------- # End of pre script # ---------------------------------------------------------------- echo "$(date): Pre script complete." | tee /dev/tty8 chvt 6 ) > /tmp/rht-ks-pre.log 2>&1 %end # ---------------------------------------------------------------- # post --nochroot script # goals: # + migrate all pre logging/files to /mnt/sysimage # + foundation0: make usb available to chroot'd environment # + foundation0: copy ks files from usb media to /mnt/sysimage # + foundation0|exam: copy version.txt to /root/rhci-version.txt # + exam server: installs need the repo copied to the local drive # ---------------------------------------------------------------- %post --nochroot ( set -x chvt 8 echo "$(date): Beginning post nochroot script..." | tee /dev/tty8 # ---------------------------------------------------------------- # migrate all pre logging/files to /mnt/sysimage # ---------------------------------------------------------------- echo "Migrate pre logging/files..." | tee /dev/tty8 cp /tmp/rht-ks-pre.log /mnt/sysimage/root/rht-ks-pre.log cp /tmp/rht /mnt/sysimage/etc/rht cp /tmp/rht-ksvars /mnt/sysimage/etc/rht-ksvars source /tmp/rht source /tmp/rht-ksvars # ---------------------------------------------------------------- # foundation0: make usb available to chroot'd environment # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then echo "Make usb available to post..." | tee /dev/tty8 [[ ! -d /mnt/sysimage/run/install/isodir ]] && mkdir -p /mnt/sysimage/run/install/isodir mount --bind /run/install/isodir /mnt/sysimage/run/install/isodir fi # ---------------------------------------------------------------- # foundation0: copy ks files from usb media to /mnt/sysimage # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then echo "Copy ks files from usb..." | tee /dev/tty8 mkdir -p /mnt/sysimage${RHTINST_MOUNT} cp -a /run/install/isodir/boot/ks /mnt/sysimage${RHTINST_MOUNT} RHTUSB=$(ls -1 /run/install/isodir/ks/rht-usb-* 2>/dev/null | tail -n1) cp ${RHTUSB} /mnt/sysimage/usr/local/bin/rht-usb chmod +x /mnt/sysimage/usr/local/bin/rht-usb fi # ---------------------------------------------------------------- # foundation0|exam: copy version.txt to /root/rhci-version.txt # ---------------------------------------------------------------- if [[ -n "${ZERO}" || ${RHT_ENROLLMENT} -eq ${EXAM} ]]; then echo "Copy version.txt file from usb..." | tee /dev/tty8 cp -a /run/install/isodir/boot/version.txt /mnt/sysimage/root/rhci-version.txt fi # ---------------------------------------------------------------- # exam server: installs need the repo copied to the local drive # ---------------------------------------------------------------- if [[ ${RHT_ENROLLMENT} -eq ${EXAM} ]]; then echo "Copy RHEL DVD to local drive..." | tee /dev/tty8 [[ -d /mnt/sysimage${EXAM_REPO_PATH} ]] || mkdir -p /mnt/sysimage${EXAM_REPO_PATH} [[ -d /mnt/repoiso ]] || mkdir -p /mnt/repoiso mount -o loop /run/install/isodir/rhel7.4/x86_64/isos/rhel-server-7.4-x86_64-dvd.iso /mnt/repoiso cp -a /mnt/repoiso/* /mnt/sysimage${EXAM_REPO_PATH} # */ for colors in vim from the previous line umount /mnt/repoiso touch /.autorelabel fi # ---------------------------------------------------------------- # End of post nochroot script # ---------------------------------------------------------------- echo "$(date): Post nochroot script complete." | tee /dev/tty8 chvt 6 ) > /mnt/sysimage/root/rht-ks-post.log 2>&1 %end # ---------------------------------------------------------------- # post script # goals: # + identify enrollment/station # + remove nobarrier option from fstab # + foundation0: copy the hypervisor layer files from RHTINST # + set up bridge br0 # + set up software repos # + foundationX: install appropriate foundation-config # + foundationX: install updates # + foundationX: import curriculum key from foundation-config # + foundation0: backward compatible hack for classroom v7.0 VMs # + foundation0: if builder environment, install additional rpm # + foundation0: copy the course files if course code passed as argument # + foundation0: ravello: no ssh passwords, install tarball, turn on eth1 # + foundationX: register to foundation0 # ---------------------------------------------------------------- %post ( set -x chvt 8 echo "$(date): Beginning post script..." | tee /dev/tty8 # ---------------------------------------------------------------- # Identify enrollment/station # ---------------------------------------------------------------- source /etc/rht source /etc/rht-ksvars [[ -z "${ZERO}" ]] && N=${RHT_ENROLLMENT} || N=250 # ---------------------------------------------------------------- # Remove nobarrier option from fstab # ---------------------------------------------------------------- sed -i -e 's/nobarrier/defaults/' /etc/fstab # ---------------------------------------------------------------- # foundation0: copy the hypervisor layer files from RHTINST # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then echo "Copying RHEL Hypervisor (${RHEL_RELEASE}) source to local drive..." | tee /dev/tty8 echo | tee /dev/tty8 /usr/local/bin/rht-usb courseusb RHCIfoundation 2>&1 | tee /dev/tty8 fi # ---------------------------------------------------------------- # set up bridge br0 # ---------------------------------------------------------------- echo "Creating br0 interface..." | tee /dev/tty8 echo | tee /dev/tty8 # FIXME: RHEL 7 beta (20131127.1) is creating extraneous ifcfg file # that is getting in the way of starting the first interface # on foundation0. if [[ -f /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 ]]; then rm /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 fi # Create bridge interface file. if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then echo "Configuring networking for foundation..." | tee /dev/tty8 if [[ -n "${ZERO}" ]]; then cat > /etc/sysconfig/network-scripts/ifcfg-br0 <<-EOF # Bridge Networking Interface DEVICE=br0 NAME="Bridge br0" ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR0=172.25.254.${N} PREFIX0=24 DEFROUTE=yes ZONE=trusted IPADDR1=172.25.0.250 PREFIX1=24 IPADDR2=172.25.253.${N} PREFIX2=24 DNS1=172.25.254.250 DOMAIN="ilt.example.com example.com" IPV6INIT=no PEERNTP=no PEERDNS=yes TYPE=Bridge DELAY=0 STP=no EOF if [[ ${ZERO} -ne 0 ]]; then cat >> /etc/sysconfig/network-scripts/ifcfg-br0 <<-EOF IPADDR3=172.25.${ZERO}.${N} PREFIX3=24 IPADDR4=172.25.254.${ZERO} PREFIX4=24 EOF fi else cat > /etc/sysconfig/network-scripts/ifcfg-br0 <<-EOF # Bridge Networking Interface DEVICE=br0 NAME="Bridge br0" ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR0=172.25.254.${N} PREFIX0=24 DEFROUTE=yes ZONE=trusted IPADDR1=172.25.${RHT_ENROLLMENT}.250 PREFIX1=24 DNS1=172.25.254.250 DOMAIN="ilt.example.com example.com" IPV6INIT=no PEERNTP=no PEERDNS=yes TYPE=Bridge DELAY=0 STP=no EOF fi echo "Adding static routes..." | tee /dev/tty8 cat > /etc/sysconfig/network-scripts/route-br0 <<-EOF 172.25.0.0/16 via 172.25.254.254 EOF if [[ -z "${RAVCMD}" ]]; then if [[ -z "${ZERO}" ]]; then cat >> /etc/sysconfig/network-scripts/route-br0 <<-EOF 172.25.253.0/24 via 172.25.254.250 EOF cat >> /etc/sysconfig/network <<-EOF GATEWAY=172.25.254.250 EOF fi fi else echo "Configuring networking for exam server..." | tee /dev/tty8 cat > /etc/sysconfig/network-scripts/ifcfg-br0 <<-EOF # Bridge Networking Interface DEVICE=br0 NAME="Bridge ${NIC1}" ONBOOT=yes BOOTPROTO=none IPADDR=192.168.0.254 PREFIX=24 GATEWAY=192.168.0.254 DEFROUTE=yes PREFIX=24 DNS1=192.168.0.254 DOMAIN="example.com" IPV6INIT=no PEERNTP=no PEERDNS=yes TYPE=Bridge DELAY=0 STP=no EOF fi HWADDRLINE=$(grep HWADDR /etc/sysconfig/network-scripts/ifcfg-${NIC1} | tr -d '"') UUIDLINE=$(grep UUID /etc/sysconfig/network-scripts/ifcfg-${NIC1} | tr -d '"') if [[ $((RHT_ENROLLMENT/512)) -eq 0 ]]; then # Attach NIC1 to the bridge br0 cat > /etc/sysconfig/network-scripts/ifcfg-${NIC1} <<-EOF DEVICE=${NIC1} NM_CONTROLLED=yes BOOTPROTO=none ${HWADDRLINE} ${UUIDLINE} BRIDGE=br0 ONBOOT=yes TYPE=Ethernet NAME="System ${NIC1}" EOF else # standalone just clears the networking config cat > /etc/sysconfig/network-scripts/ifcfg-${NIC1} <<-EOF DEVICE=${NIC1} NM_CONTROLLED=yes BOOTPROTO=none ${HWADDRLINE} ${UUIDLINE} ONBOOT=no TYPE=Ethernet NAME="System ${NIC1}" EOF fi # ---------------------------------------------------------------- # set up software repos # ---------------------------------------------------------------- echo "Set up software repositories..." | tee /dev/tty8 echo | tee /dev/tty8 if [[ -n "${ZERO}" ]]; then cat > "/etc/yum.repos.d/rhel-dvd.repo" <<-EOF [rhel-dvd] name="Local classroom copy of dvd" baseurl=file://${RHTINST_MOUNT}/${RHELH_TREE}/dvd gpgcheck=0 [ucf-upd] name="Updates for UCF physical systems" baseurl=file://${RHTINST_MOUNT}/${RHELH_TREE}/ucfupdates gpgcheck=0 EOF elif [[ ${RHT_ENROLLMENT} -eq ${EXAM} ]]; then cat > "/etc/yum.repos.d/rhel-dvd.repo" <<-EOF [rhel-dvd] name="Local classroom copy of dvd" baseurl=file://${EXAM_REPO_PATH} gpgcheck=0 EOF else cat > "/etc/yum.repos.d/rhel-dvd.repo" <<-EOF [rhel-dvd] name="Remote classroom copy of dvd" baseurl=http://172.25.254.250/${RHELH_TREE}/dvd gpgcheck=0 [ucf-upd] name="Updates for UCF physical systems" baseurl=http://172.25.254.250/${RHELH_TREE}/ucfupdates gpgcheck=0 EOF fi # ---------------------------------------------------------------- # foundationX: install appropriate foundation-config # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then echo "Installing foundation0-config..." | tee /dev/tty8 echo | tee /dev/tty8 # Since files under ucf are manually put there, we wait to # run createrepo until here. # FIXME: For some reason umask is 077 in here.... createrepo -v ${RHTINST_MOUNT}/ucf | tee /dev/tty8 chmod -R +r ${RHTINST_MOUNT}/ucf/repodata chmod +x ${RHTINST_MOUNT}/ucf/repodata # While the SELinux context from Kickstart works, anyone making # changes afterwards, will be unpleasantly surprised, so let us # fix it here. semanage fcontext -a -t public_content_t ${RHTINST_MOUNT}'(/.*)?' restorecon -RFvv ${RHTINST_MOUNT} cat > "/etc/yum.repos.d/rht-ucf.repo" <<-EOF [rht-ext] name="RHT UCF" baseurl=file://${RHTINST_MOUNT}/ucf gpgcheck=0 EOF yum -y install /root/foundation0-config-*.rpm | tee /dev/tty8 elif [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then echo "Installing foundation-config..." | tee /dev/tty8 echo | tee /dev/tty8 cat > "/etc/yum.repos.d/rht-ucf.repo" <<-EOF [rht-ext] name="RHT UCF" baseurl=http://172.25.254.250/ucf gpgcheck=0 EOF yum -y install foundation-config | tee /dev/tty8 fi # ---------------------------------------------------------------- # foundationX: install updates # ---------------------------------------------------------------- if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then echo "Installing updates..." | tee /dev/tty8 echo | tee /dev/tty8 yum -y update | tee /dev/tty8 fi # ---------------------------------------------------------------- # foundationX: import curriculum key from foundation-config # ---------------------------------------------------------------- if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then rpm --import /etc/pki/rpm-gpg/RHT-GPG-KEY-curriculum fi # ---------------------------------------------------------------- # foundation0: install offline roster/survey packges # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then yum -y install redhat-training-{roster,survey} 2>&1 | tee /dev/tty8 fi # ---------------------------------------------------------------- # foundation0: backward compatible hack for classroom v7.0 VMs # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then # The redhat-survey has been moved to a generic directory, but # existing classroom VMs are expecting to find it here as a repo # rather than as a file. REPOHACK=${RHTINST_MOUNT}/rhel7.0/x86_64/extras # FIXME: For some reason umask is 077 in here.... createrepo -v ${REPOHACK} | tee /dev/tty8 chmod -R +r ${REPOHACK}/repodata chmod +x ${REPOHACK}/repodata restorecon -RFvv ${REPOHACK} fi # ---------------------------------------------------------------- # foundation0: if builder environment, install additional manifest # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then if echo ${RHT_ROLE} | egrep -i 'build' ; then echo "Installing builder environment (${RHT_ROLE})..." | tee /dev/tty8 echo | tee /dev/tty8 # Copy manifest /usr/local/bin/rht-usb courseusb RHCI${RHT_ROLE} 2>&1 | tee /dev/tty8 # Install ansible yum -y install ansible 2>&1 | tee /dev/tty8 fi fi # ---------------------------------------------------------------- # foundation0: copy the course files if course code passed as argument # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then if [[ -n "${COURSETECH}" ]]; then echo "Installing course ${COURSETECH}..." | tee /dev/tty8 echo | tee /dev/tty8 /usr/local/bin/rht-usb courseusb ${COURSETECH} 2>&1 | tee /dev/tty8 /usr/local/bin/rht-setcourse ${COURSE} | tee /dev/tty8 fi fi # ---------------------------------------------------------------- # foundation0: ravello: no ssh passwords, install tarball, turn on eth1 # ---------------------------------------------------------------- if [[ -n "${ZERO}" ]]; then if [[ -n "${RAVCMD}" ]]; then echo "Making Ravello sshd reject passwords..." | tee /dev/tty8 echo | tee /dev/tty8 sed -i -e "s/^PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config echo "Installing RHCIdevel manifest..." | tee /dev/tty8 echo | tee /dev/tty8 /usr/local/bin/rht-usb courseusb RHCIdevel 2>&1 | tee /dev/tty8 # Install ansible yum -y install ansible 2>&1 | tee /dev/tty8 # Enable second NIC if [[ -f /etc/sysconfig/network-scripts/ifcfg-${NIC2} ]]; then echo "Enabling ${NIC2}..." | tee /dev/tty8 echo | tee /dev/tty8 HWADDRLINE=$(grep HWADDR /etc/sysconfig/network-scripts/ifcfg-${NIC2} | tr -d '"') UUIDLINE=$(grep UUID /etc/sysconfig/network-scripts/ifcfg-${NIC2} | tr -d '"') cat > /etc/sysconfig/network-scripts/ifcfg-${NIC2} <<-EOF DEVICE=${NIC2} BOOTPROTO=static ${HWADDRLINE} ${UUIDLINE} ONBOOT=yes NM_CONTROLLED=yes TYPE=Ethernet NAME="System ${NIC2}" IPADDR=10.1.1.10 NETMASK=255.255.0.0 GATEWAY=10.1.0.2 USERCTL=yes IPV6INIT=no PEERNTP=no PEERDNS=no ZONE=external EOF fi fi fi # ---------------------------------------------------------------- # foundationX: register to foundation0 # ---------------------------------------------------------------- if [[ -z "${ZERO}" && ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then echo "Registering with foundation0..." | tee /dev/tty8 echo | tee /dev/tty8 wget -O /tmp/rht-register http://172.25.254.250/cgi-bin/register.sh?ucfname=foundation${RHT_ENROLLMENT}.ilt.example.com fi # ---------------------------------------------------------------- # foundationX: prep destroy grub entry # ---------------------------------------------------------------- if [[ ${RHT_ENROLLMENT} -ne ${EXAM} ]]; then # If installing foundation0, copy files from /content if [[ -n "${ZERO}" ]]; then echo "Copying destroy from ${RHTINST_MOUNT}..." | tee /dev/tty8 echo | tee /dev/tty8 cp ${RHTINST_MOUNT}/${RHELH_TREE}/dvd/isolinux/vmlinuz /boot/vmlinuz-anaconda cp ${RHTINST_MOUNT}/${RHELH_TREE}/dvd/isolinux/initrd.img /boot/initrd.img-anaconda mkdir /boot/LiveOS cp ${RHTINST_MOUNT}/${RHELH_TREE}/dvd/LiveOS/squashfs.img /boot/LiveOS/squashfs.img cp ${RHTINST_MOUNT}/ks/destroy.ks /boot/destroy.ks # else download files from f0 else echo "Downloading destroy from f0..." | tee /dev/tty8 echo | tee /dev/tty8 wget -O /boot/vmlinuz-anaconda http://172.25.254.250/${RHELH_TREE}/dvd/isolinux/vmlinuz | tee /dev/tty8 #tftp get 172.25.254.250:vmlinuz /boot/vmlinuz-anaconda | tee /dev/tty8 wget -O /boot/initrd.img-anaconda http://172.25.254.250/${RHELH_TREE}/dvd/isolinux/initrd.img | tee /dev/tty8 #tftp get 172.25.254.250:initrd.img /boot/initrd.img-anaconda | tee /dev/tty8 mkdir /boot/LiveOS wget -O /boot/LiveOS/squashfs.img http://172.25.254.250/${RHELH_TREE}/dvd/LiveOS/squashfs.img | tee /dev/tty8 wget -O /boot/destroy.ks http://172.25.254.250/ks/destroy.ks | tee /dev/tty8 fi # Create grubby entry grubby --title=Destroy --add-kernel=/boot/vmlinuz-anaconda --initrd=/boot/initrd.img-anaconda --args="ks=hd:sda1:/boot/destroy.ks stage2=hd:sda1:/boot poweroff" fi # ---------------------------------------------------------------- # End of post script # ---------------------------------------------------------------- echo "$(date): Post script complete." | tee /dev/tty8 chvt 6 ) >> /root/rht-ks-post.log 2>&1 %end %addon com_redhat_kdump --disable --reserve-mb='auto' %end