url --url=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/os/

text
# System bootloader configuration
bootloader --location=mbr
network --bootproto=dhcp --hostname=test01.test-kickstart.invalid

repo --name=beaker-repos_addons_ScalableFileSystem --cost=100 --baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/os/addons/ScalableFileSystem
repo --name=beaker-repos_Workstation-optional --cost=100 --baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation-optional/x86_64/os
repo --name=beaker-repos_debug_Workstation --cost=100 --baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/debuginfo
repo --name=beaker-repos_debug_Workstation_optional --cost=100 --baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation-optional/x86_64/debuginfo
repo --name=beaker-repos_Workstation --cost=100 --baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/os/

firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8

reboot
#Root password
rootpw --iscrypted $1$beaker$yMeLK4p1IVkFa80RyTkpE.
# SELinux configuration
selinux --enforcing


# System timezone
timezone America/New_York

zerombr
clearpart --all --initlabel

autopart
# no snippet data for RedHatEnterpriseLinux7
# no snippet data for RedHatEnterpriseLinux
# no snippet data for system

%packages --ignoremissing
# Task requirements will be installed by the harness
# no snippet data for packages
chrony
%end



%pre --log=/dev/console
set -x
# Some distros have curl in their minimal install set, others have wget.
# We define a wrapper function around the best available implementation
# so that the rest of the script can use that for making HTTP requests.
if command -v curl >/dev/null ; then
    # Older curl versions lack --retry
    if curl --help 2>&1 | grep -q .*--retry ; then
        function fetch() {
            curl -L --retry 20 --remote-time -o "$1" "$2"
        }
    else
        function fetch() {
            curl -L --remote-time -o "$1" "$2"
        }
    fi
elif command -v wget >/dev/null ; then
    # In Anaconda images wget is actually busybox
    if wget --help 2>&1 | grep -q BusyBox ; then
        function fetch() {
            wget -O "$1" "$2"
        }
    else
        function fetch() {
            wget --tries 20 -O "$1" "$2"
        }
    fi
else
    echo "No HTTP client command available!"
    function fetch() {
        false
    }
fi

# Check in with Beaker Server
fetch - http://lab.test-kickstart.invalid:8000/install_start/@RECIPEID@

if command -v python3 >/dev/null ; then
   fetch /tmp/anamon http://lab.test-kickstart.invalid/beaker/anamon3
   python_command="python3"
elif [ -f /usr/libexec/platform-python ] && \
     /usr/libexec/platform-python --version 2>&1 | grep -q "Python 3" ; then
   fetch /tmp/anamon http://lab.test-kickstart.invalid/beaker/anamon3
   python_command="/usr/libexec/platform-python"
else
   fetch /tmp/anamon http://lab.test-kickstart.invalid/beaker/anamon
   python_command="python"
fi
$python_command /tmp/anamon --recipe-id @RECIPEID@ --xmlrpc-url 'http://lab.test-kickstart.invalid:8000/RPC2'
# no snippet data for RedHatEnterpriseLinux7_pre
# no snippet data for RedHatEnterpriseLinux_pre
# no snippet data for system_pre
%end

%post --log=/dev/console
set -x
# Some distros have curl in their minimal install set, others have wget.
# We define a wrapper function around the best available implementation
# so that the rest of the script can use that for making HTTP requests.
if command -v curl >/dev/null ; then
    # Older curl versions lack --retry
    if curl --help 2>&1 | grep -q .*--retry ; then
        function fetch() {
            curl -L --retry 20 --remote-time -o "$1" "$2"
        }
    else
        function fetch() {
            curl -L --remote-time -o "$1" "$2"
        }
    fi
elif command -v wget >/dev/null ; then
    # In Anaconda images wget is actually busybox
    if wget --help 2>&1 | grep -q BusyBox ; then
        function fetch() {
            wget -O "$1" "$2"
        }
    else
        function fetch() {
            wget --tries 20 -O "$1" "$2"
        }
    fi
else
    echo "No HTTP client command available!"
    function fetch() {
        false
    }
fi

# Check in with Beaker Server, let it know our hostname, and
# record our install time.

# We will try a number of different places to figure out the system's FQDN.
# In all cases we will only accept a real FQDN (no "localhost", and must have
# a domain portion). DNS is our preferred source, otherwise the installer
# should have stored a hostname in /etc based on the kickstart or DHCP info.
# As a last resort we will use the system's first IP address.
function find_fqdn() {
    local fqdn=
    # hostname -f is the most future-proof approach, but it isn't always reliable
    fqdn=$(hostname -f)
    if [[ "$fqdn" == *.* && "$fqdn" != localhost.* ]] ; then echo "$fqdn" ; return ; fi
    # Preferred fallback if the OS is recent enough to provide it
    fqdn=$(cat /etc/hostname)
    if [[ "$fqdn" == *.* && "$fqdn" != localhost.* ]] ; then echo "$fqdn" ; return ; fi
    # Red Hat-based systems prior to systemd will have this
    fqdn=$(grep ^HOSTNAME= /etc/sysconfig/network | cut -f2- -d=)
    if [[ "$fqdn" == *.* && "$fqdn" != localhost.* ]] ; then echo "$fqdn" ; return ; fi
    # Getting desperate... pick the first local IP address
    ipaddr=$(hostname -i)
    if [[ "$ipaddr" != "127.0.0.1" ]] ; then echo "$ipaddr" ; return ; fi
    # Getting even more desperate (RHEL5 and earlier)
    ip addr show | grep -v ' lo' | grep -Po '(?<=inet )[0-9.]+'
}
REPORTED_FQDN=$(find_fqdn)
fetch - "http://lab.test-kickstart.invalid:8000/install_done/@RECIPEID@/$REPORTED_FQDN"
fetch - http://lab.test-kickstart.invalid:8000/nopxe/test01.test-kickstart.invalid
echo @RECIPEID@ > /root/RECIPE.TXT

# If netboot_method= is found in /proc/cmdline record it to /root
netboot_method=$(grep -oP "(?<=netboot_method=)[^\s]+(?=)" /proc/cmdline)
if [ -n "$netboot_method" ]; then
echo $netboot_method >/root/NETBOOT_METHOD.TXT
fi

# Enable post-install boot notification

if command -v python3 >/dev/null ; then
    fetch /usr/local/sbin/anamon http://lab.test-kickstart.invalid/beaker/anamon3
elif [ -f /usr/libexec/platform-python ] && \
     /usr/libexec/platform-python --version 2>&1 | grep -q "Python 3" ; then
    fetch /usr/local/sbin/anamon http://lab.test-kickstart.invalid/beaker/anamon3
    sed -i 's/#!\/usr\/bin\/python3/#!\/usr\/libexec\/platform-python/' /usr/local/sbin/anamon
else
    fetch /usr/local/sbin/anamon http://lab.test-kickstart.invalid/beaker/anamon
fi
chmod 755 /usr/local/sbin/anamon

# OS without `initscripts` need to use systemd
if [ -e /etc/init.d/functions ]; then
    fetch /etc/rc.d/init.d/anamon http://lab.test-kickstart.invalid/beaker/anamon.init

    chmod 755 /etc/rc.d/init.d/anamon
    if selinuxenabled &>/dev/null ; then
        restorecon /etc/rc.d/init.d/anamon /usr/local/sbin/anamon
    fi

    chkconfig --add anamon
else
    fetch /etc/systemd/system/anamon.service http://lab.test-kickstart.invalid/beaker/anamon.service
    systemctl enable anamon
fi

cat << __EOT__ > /etc/sysconfig/anamon
XMLRPC_URL="http://lab.test-kickstart.invalid:8000/RPC2"
RECIPE_ID="@RECIPEID@"
LOGFILES="/var/log/boot.log /var/log/messages /var/log/dmesg"
__EOT__

if [ -f /etc/sysconfig/readahead ] ; then
    :
    cat >>/etc/sysconfig/readahead <<EOF

# readahead conflicts with auditd, see bug 561486 for detailed explanation.
#
# Should a task need to change these settings, it must revert to this state
# when test is done.

READAHEAD_COLLECT="no"
READAHEAD_COLLECT_ON_RPM="no"
EOF
fi
systemctl disable systemd-readahead-collect.service

if [ -e /etc/sysconfig/ntpdate ] ; then
    systemctl enable ntpdate.service
fi
if [ -e "/etc/sysconfig/ntpd" ]; then
    systemctl enable ntpd.service
    GOT_G=$(/bin/cat /etc/sysconfig/ntpd | grep -E '^OPTIONS' | grep '\-g')

    if [ -z "$GOT_G" ]; then
        /bin/sed -i -r 's/(^OPTIONS\s*=\s*)(['\''|"])(.+)$/\1\2\-x \3 /' /etc/sysconfig/ntpd
    fi
fi
if [ -e /etc/chrony.conf ] ; then
    cp /etc/chrony.conf{,.orig}
    # use only DHCP-provided time servers, no default pool servers
    sed -i '/^server /d' /etc/chrony.conf
    cp /etc/sysconfig/network{,.orig}
    # setting iburst should speed up initial sync
    # https://bugzilla.redhat.com/show_bug.cgi?id=787042#c12
    echo NTPSERVERARGS=iburst >>/etc/sysconfig/network
    systemctl disable ntpd.service
    systemctl disable ntpdate.service
    systemctl enable chronyd.service
    systemctl enable chrony-wait.service
fi

if efibootmgr &>/dev/null ; then
    # The installer should have added a new boot entry for the OS
    # at the top of the boot order. We move it to the end of the order
    # and set it as BootNext instead.
    boot_order=$(efibootmgr | awk '/BootOrder/ { print $2 }')
    os_boot_entry=$(cut -d, -f1 <<<"$boot_order")
    new_boot_order=$(cut -d, -f2- <<<"$boot_order"),"$os_boot_entry"
    efibootmgr -o "$new_boot_order"
    efibootmgr -n "$os_boot_entry"
    # save the boot entry for later, so that rhts-reboot can set BootNext as well
    echo "$os_boot_entry" >/root/EFI_BOOT_ENTRY.TXT
fi


#Add Task Repo
cat <<"EOF" >/etc/yum.repos.d/beaker-tasks.repo
[beaker-tasks]
name=beaker-tasks
baseurl=@REPOS@@RECIPEID@
enabled=1
gpgcheck=0
skip_if_unavailable=0
EOF


# Add Harness Repo
cat <<"EOF" >/etc/yum.repos.d/beaker-harness.repo
[beaker-harness]
name=beaker-harness
baseurl=@HARNESS@RedHatEnterpriseLinux7/
enabled=1
gpgcheck=0
EOF

# Add distro and custom Repos
cat <<"EOF" >/etc/yum.repos.d/beaker-repos_addons_ScalableFileSystem.repo
[beaker-repos_addons_ScalableFileSystem]
name=beaker-repos_addons_ScalableFileSystem
baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/os/addons/ScalableFileSystem
enabled=1
gpgcheck=0
skip_if_unavailable=1
EOF
cat <<"EOF" >/etc/yum.repos.d/beaker-repos_Workstation-optional.repo
[beaker-repos_Workstation-optional]
name=beaker-repos_Workstation-optional
baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation-optional/x86_64/os
enabled=1
gpgcheck=0
skip_if_unavailable=1
EOF
cat <<"EOF" >/etc/yum.repos.d/beaker-repos_debug_Workstation.repo
[beaker-repos_debug_Workstation]
name=beaker-repos_debug_Workstation
baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/debuginfo
enabled=1
gpgcheck=0
skip_if_unavailable=1
EOF
cat <<"EOF" >/etc/yum.repos.d/beaker-repos_debug_Workstation_optional.repo
[beaker-repos_debug_Workstation_optional]
name=beaker-repos_debug_Workstation_optional
baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation-optional/x86_64/debuginfo
enabled=1
gpgcheck=0
skip_if_unavailable=1
EOF
cat <<"EOF" >/etc/yum.repos.d/beaker-repos_Workstation.repo
[beaker-repos_Workstation]
name=beaker-repos_Workstation
baseurl=http://lab.test-kickstart.invalid/distros/RHEL-7.0-20120314.0/compose/Workstation/x86_64/os/
enabled=1
gpgcheck=0
skip_if_unavailable=1
EOF


if command -v dnf >/dev/null ; then
   package_command="dnf"
else
   package_command="yum"
fi
# fill the yum cache and redirect output to /dev/null
# This speeds up yum because of a bug where it will update stdout too often.
# http://lists.baseurl.org/pipermail/yum-devel/2011-December/008857.html
$package_command check-update -y > /dev/null 2>&1 || true
cat <<"EOF" >/etc/profile.d/beaker-harness-env.sh
export BEAKER_LAB_CONTROLLER_URL="http://lab.test-kickstart.invalid:8000/"
export BEAKER_LAB_CONTROLLER=lab.test-kickstart.invalid
export BEAKER_RECIPE_ID=@RECIPEID@
export BEAKER_HUB_URL="@BEAKER@"
EOF
cat <<"EOF" >/etc/profile.d/beaker-harness-env.csh
setenv BEAKER_LAB_CONTROLLER_URL "http://lab.test-kickstart.invalid:8000/"
setenv BEAKER_LAB_CONTROLLER lab.test-kickstart.invalid
setenv BEAKER_RECIPE_ID @RECIPEID@
setenv BEAKER_HUB_URL "@BEAKER@"
EOF

if command -v dnf >/dev/null ; then
   package_command="dnf"
else
   package_command="yum"
fi
$package_command -y install restraint-rhts

#Add test user account
useradd --password '$6$oIW3o2Mr$XbWZKaM7nA.cQqudfDJScupXOia5h1u517t6Htx/Q/MgXm82Pc/OcytatTeI4ULNWOMJzvpCigWiL4xKP9PX4.' test
cat <<"EOF" >/etc/profile.d/beaker.sh
export BEAKER="@BEAKER@"
export BEAKER_JOB_WHITEBOARD=''
export BEAKER_RECIPE_WHITEBOARD=''
EOF
cat <<"EOF" >/etc/profile.d/beaker.csh
setenv BEAKER "@BEAKER@"
setenv BEAKER_JOB_WHITEBOARD ''
setenv BEAKER_RECIPE_WHITEBOARD ''
EOF

cat << EOF > /etc/profile.d/rh-env.sh
export LAB_CONTROLLER=lab.test-kickstart.invalid
export DUMPSERVER=netdump.test-kickstart.invalid
export NFSSERVERS="RHEL3,rhel3-nfs.test-kickstart.invalid:/export/home RHEL4,rhel4-nfs.test-kickstart.invalid:/export/home RHEL5,rhel5-nfs.test-kickstart.invalid:/export/home RHEL6,rhel6-nfs.test-kickstart.invalid:/export/home NETAPP, SOLARIS,"
export LOOKASIDE=http://download.test-kickstart.invalid/lookaside/
export BUILDURL=http://download.test-kickstart.invalid
EOF
cat << EOF > /etc/profile.d/rh-env.csh
setenv LAB_CONTROLLER lab.test-kickstart.invalid
setenv DUMPSERVER netdump.test-kickstart.invalid
setenv NFSSERVERS "RHEL3,rhel3-nfs.test-kickstart.invalid:/export/home RHEL4,rhel4-nfs.test-kickstart.invalid:/export/home RHEL5,rhel5-nfs.test-kickstart.invalid:/export/home RHEL6,rhel6-nfs.test-kickstart.invalid:/export/home NETAPP, SOLARIS,"
setenv LOOKASIDE http://download.test-kickstart.invalid/lookaside/
setenv BUILDURL http://download.test-kickstart.invalid
EOF
# Disable rhts-compat for Fedora15/RHEL7 and newer.
cat >> /etc/profile.d/task-overrides-rhts.sh <<END
export RHTS_OPTION_COMPATIBLE=
export RHTS_OPTION_COMPAT_SERVICE=
END
# no snippet data for RedHatEnterpriseLinux7_post
# no snippet data for RedHatEnterpriseLinux_post
# no snippet data for system_post
%end


%post
set -x
# Some distros have curl in their minimal install set, others have wget.
# We define a wrapper function around the best available implementation
# so that the rest of the script can use that for making HTTP requests.
if command -v curl >/dev/null ; then
    # Older curl versions lack --retry
    if curl --help 2>&1 | grep -q .*--retry ; then
        function fetch() {
            curl -L --retry 20 --remote-time -o "$1" "$2"
        }
    else
        function fetch() {
            curl -L --remote-time -o "$1" "$2"
        }
    fi
elif command -v wget >/dev/null ; then
    # In Anaconda images wget is actually busybox
    if wget --help 2>&1 | grep -q BusyBox ; then
        function fetch() {
            wget -O "$1" "$2"
        }
    else
        function fetch() {
            wget --tries 20 -O "$1" "$2"
        }
    fi
else
    echo "No HTTP client command available!"
    function fetch() {
        false
    }
fi
# Check in with Beaker Server, record our postinstall time.
fetch - http://lab.test-kickstart.invalid:8000/postinstall_done/@RECIPEID@
# Give anamon a chance to finish collecting logs.
sleep 10
%end
