cat <<"EOF" >/etc/profile.d/beaker-harness-env.sh
export BEAKER_LAB_CONTROLLER_URL="http://{{ lab_controller.fqdn }}:8000/"
export BEAKER_LAB_CONTROLLER={{ lab_controller.fqdn }}
export BEAKER_RECIPE_ID={{ recipe.id }}
export BEAKER_HUB_URL="{{ absolute_url('/', labdomain=True) }}"
EOF
cat <<"EOF" >/etc/profile.d/beaker-harness-env.csh
setenv BEAKER_LAB_CONTROLLER_URL "http://{{ lab_controller.fqdn }}:8000/"
setenv BEAKER_LAB_CONTROLLER {{ lab_controller.fqdn }}
setenv BEAKER_RECIPE_ID {{ recipe.id }}
setenv BEAKER_HUB_URL "{{ absolute_url('/', labdomain=True) }}"
EOF

if command -v dnf >/dev/null ; then
   package_command="dnf"
else
   package_command="yum"
fi
{% if distro_tree is arch('ia64') %}
# We want to avoid installing i386/i686 harness packages on ia64, because ia64
# "multilib" support is kind of crazy and broken. See RHBZ#1328153 for details.
# So let's temporarily set multilib_policy=best so that only the ia64 harness
# packages will be picked. We restore the default config afterwards, to keep
# the environment clean. (multilib_policy=best is the default in RHEL6+.)
cp -p /etc/yum.conf{,.orig}
echo multilib_policy=best >>/etc/yum.conf
$package_command{{ ' ' + yum_install_extra_opts if yum_install_extra_opts is defined else '' }} -y install {{ harness if harness is string else harness|join(' ')}}
mv /etc/yum.conf{.orig,}
{% else %}
$package_command{{ ' ' + yum_install_extra_opts if yum_install_extra_opts is defined else '' }} -y install {{ harness if harness is string else harness|join(' ')}}
{% endif %}
