
RHEL/CentOS 8 dropped support for some older hardware that is still in use. Since CentOS 7 has Python 3, let's support it for now. Also fixes an issue with C.UTF-8 locale which does not seem to work on CentOS 7 (and actually causes a failure with newer python packages). Change-Id: I1b5797b030ef896ad4b2a95a504a0215ca6ee574
68 lines
2.1 KiB
Bash
Executable File
68 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
SCRIPTDIR=$(dirname $0)
|
|
IPADIR=/tmp/ironic-python-agent
|
|
UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt
|
|
VENVDIR=/opt/ironic-python-agent
|
|
|
|
IPA_PYTHON_VERSION=$DIB_PYTHON_VERSION
|
|
IPA_PYTHON="$DIB_PYTHON"
|
|
|
|
case "$DISTRO_NAME" in
|
|
centos7|rhel7)
|
|
# NOTE(dtantsur): C.UTF-8 doesn't seem to exist in CentOS 7
|
|
export LC_ALL=en_US.UTF-8
|
|
|
|
if grep -q 'Python :: 3 :: Only' $IPADIR/setup.cfg; then
|
|
echo "WARNING: using Python 3 on CentOS 7, this is not recommended"
|
|
${YUM:-yum} install -y python3 python3-devel
|
|
IPA_PYTHON=python3
|
|
IPA_PYTHON_VERSION=3
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# create the virtual environment using the default python
|
|
if [ $IPA_PYTHON_VERSION == 3 ]; then
|
|
$IPA_PYTHON -m venv $VENVDIR
|
|
else
|
|
$IPA_PYTHON -m virtualenv $VENVDIR
|
|
fi
|
|
|
|
# pip might be an older version which does not support the -c option, therefore
|
|
# upgrade it first. This is no-op when a new enough version is available.
|
|
$VENVDIR/bin/pip install 'pip>=7.1'
|
|
|
|
# install IPA inside the virtual environment
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS $IPADIR --install-option="--install-scripts=/usr/local/bin/"
|
|
|
|
case "$DIB_INIT_SYSTEM" in
|
|
upstart)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.conf /etc/init/ironic-python-agent.conf
|
|
;;
|
|
systemd)
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service
|
|
;;
|
|
sysv)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.init /etc/init.d/ironic-python-agent.init
|
|
update-rc.d ironic-python-agent.init defaults
|
|
;;
|
|
*)
|
|
echo "Unsupported init system"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Copying the self signed certificate for request library
|
|
if [ -f /tmp/in_target.d/ipa-trusted-cert.pem ]; then
|
|
cat /tmp/in_target.d/ipa-trusted-cert.pem >> $($VENVDIR/bin/python -c "import requests; print(requests.certs.where())")
|
|
fi
|