# Kickstart file for galaxys 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 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 # ---------------------------------------------------------------- # 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="foundation2" echo "RHT_ROLE=${ROLE}" >> /tmp/rht COURSE="" echo "RHT_COURSE=${COURSE}" >> /tmp/rht echo "RHT_TITLE=" >> /tmp/rht echo "RHT_VMS=" >> /tmp/rht source /tmp/rht echo "RHT_PRIVUSEOVS=" >> /tmp/rht echo "RHT_NOSTARTVMS=" >> /tmp/rht echo "RHT_NOFINISHVMS=" >> /tmp/rht RHEL_RELEASE=rhel7.4 RHELH_TREE=${RHEL_RELEASE}/x86_64 cat > /tmp/rht-ksvars <<-EOF RHEL_RELEASE=${RHEL_RELEASE} RHELH_TREE=${RHELH_TREE} UCF_RELEASE=5.r2017111415gitdd10090 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 cat >> /tmp/rht-ksconfig <<-EOF rootpw --iscrypted \$6\$oZ1JGQiQ\$0lau6DEHSV81iQ54SJyjhI7s9DvAz2Ly5JVwGxMXJqDodk61DXZnF79ibX.scEeHKIe1tBTqLSCIfYV2k3AuW1 user --name=kiosk --password=redhat --plaintext EOF echo "Adding reboot to instruction list..." | tee /dev/tty8 cat >> /tmp/rht-ksconfig <<-EOF reboot EOF # ---------------------------------------------------------------- # 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 cat >> /tmp/rht-ksconfig <<-EOF bootloader --location=mbr --boot-drive=$MAINDISK 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 [[ ${RHT_ENROLLMENT} -ne 0 ]] && N=${RHT_ENROLLMENT} || N=251 # 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, shift down if [[ -n "${NIC1}" ]]; then NIC2=${NIC1} fi NIC1=${nic} 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" cat >> /tmp/rht-ksconfig <<-EOF network --bootproto=static --ip=172.25.253.${N} --netmask=255.255.255.0 --gateway=172.25.253.254 --nameserver=172.25.253.250 --device=${NIC1} --hostname=galaxy${RHT_ENROLLMENT}.ilt.example.com ${NICACTIVATE} EOF 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 # ---------------------------------------------------------------- echo "Downloading keyboard, lang, and timezone on galaxyX..." | tee /dev/tty8 wget -O /tmp/rht-locale http://172.25.253.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.253.250/ks/rht-locale-packages | tee /dev/tty8 cat /tmp/rht-locale-packages >> /tmp/rht-packages # ---------------------------------------------------------------- # add appropriate packages # ---------------------------------------------------------------- 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 # ---------------------------------------------------------------- # End of pre script # ---------------------------------------------------------------- echo "$(date): Pre script complete." | tee /dev/tty8 ) > /tmp/rht-ks-pre.log 2>&1 %end # ---------------------------------------------------------------- # post --nochroot script # goals: # + migrate all pre logging/files to /mnt/sysimage # ---------------------------------------------------------------- %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 # ---------------------------------------------------------------- # 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 # + set up bridge br0 # + set up software repos # + install foundation-config # + import curriculum key from foundation-config # + register to foundation0 # ---------------------------------------------------------------- %post ( set -x chvt 8 echo "$(date): Beginning post script..." | tee /dev/tty8 # ---------------------------------------------------------------- # Identify enrollment/station # ---------------------------------------------------------------- source /etc/rht [[ ${RHT_ENROLLMENT} -ne 0 ]] && N=${RHT_ENROLLMENT} || N=251 source /etc/rht-ksvars # ---------------------------------------------------------------- # Remove nobarrier option from fstab # ---------------------------------------------------------------- sed -i -e 's/nobarrier/defaults/' /etc/fstab # ---------------------------------------------------------------- # set up bridge br0 # ---------------------------------------------------------------- echo "Creating br0 interface..." | tee /dev/tty8 echo | tee /dev/tty8 # Create bridge interface file. echo "Configuring networking for foundation..." | tee /dev/tty8 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.253.${N} PREFIX0=24 DEFROUTE=yes IPADDR1=172.25.${RHT_ENROLLMENT}.251 PREFIX1=24 DNS1=172.25.253.250 DOMAIN="ilt.example.com example.com" IPV6INIT=no PEERNTP=no PEERDNS=yes TYPE=Bridge DELAY=0 STP=no EOF echo "Adding static routes..." | tee /dev/tty8 cat > /etc/sysconfig/network-scripts/route-br0 <<-EOF 172.25.0.0/16 via 172.25.253.254 EOF cat >> /etc/sysconfig/network-scripts/route-br0 <<-EOF 172.25.254.0/24 via 172.25.253.250 EOF cat >> /etc/sysconfig/network <<-EOF GATEWAY=172.25.253.250 EOF # Attach NIC1 to the bridge br0 HWADDRLINE=$(grep HWADDR /etc/sysconfig/network-scripts/ifcfg-${NIC1} | tr -d '"') UUIDLINE=$(grep UUID /etc/sysconfig/network-scripts/ifcfg-${NIC1} | tr -d '"') 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 # ---------------------------------------------------------------- # set up software repos # ---------------------------------------------------------------- echo "Set up software repositories..." | tee /dev/tty8 echo | tee /dev/tty8 cat > "/etc/yum.repos.d/rhel-dvd.repo" <<-EOF [rhel-dvd] name="Remote classroom copy of dvd" baseurl=http://172.25.253.250/$RHELH_TREE/dvd gpgcheck=0 EOF # ---------------------------------------------------------------- # install foundation-config # ---------------------------------------------------------------- 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.253.250/ucf gpgcheck=0 EOF yum -y install foundation-config | tee /dev/tty8 # ---------------------------------------------------------------- # import curriculum key from foundation-config # ---------------------------------------------------------------- rpm --import /etc/pki/rpm-gpg/RHT-GPG-KEY-curriculum # ---------------------------------------------------------------- # register to foundation0 # ---------------------------------------------------------------- echo "Registering with foundation0..." | tee /dev/tty8 echo | tee /dev/tty8 wget -O /tmp/rht-register http://172.25.253.250/cgi-bin/register.sh?ucfname=galaxy${RHT_ENROLLMENT}.ilt.example.com # ---------------------------------------------------------------- # 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