![Riccardo Pittau](/assets/img/avatar_default.png)
We upgrade pip only if the version is too old to not support the -c option. Change-Id: I6e633debb2bf97f397a4b3d252c25e4a41992a8d
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 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
|
|
|
|
# create the virtual environment using the default python
|
|
if [ $DIB_PYTHON_VERSION == 3 ]; then
|
|
$DIB_PYTHON -m venv $VENVDIR
|
|
else
|
|
$DIB_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
|