2019-06-23 02:17:49 +05:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
2020-01-30 12:07:32 +01:00
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
|
2019-06-23 02:17:49 +05:30
|
|
|
SCRIPTDIR=$(dirname $0)
|
2019-08-27 17:29:51 +02:00
|
|
|
IPADIR=/tmp/ironic-python-agent
|
2019-10-16 13:58:50 +02:00
|
|
|
UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt
|
2019-09-23 13:48:31 +02:00
|
|
|
VENVDIR=/opt/ironic-python-agent
|
2019-06-23 02:17:49 +05:30
|
|
|
|
2019-09-30 14:13:16 +02:00
|
|
|
# create the virtual environment using the default python
|
2020-01-29 18:31:33 +01:00
|
|
|
if [ $DIB_PYTHON_VERSION == 3 ]; then
|
|
|
|
$DIB_PYTHON -m venv $VENVDIR
|
|
|
|
else
|
|
|
|
$DIB_PYTHON -m virtualenv $VENVDIR
|
|
|
|
fi
|
2019-06-23 02:17:49 +05:30
|
|
|
|
|
|
|
# pip might be an older version which does not support the -c option, therefore upgrade first
|
2019-09-23 13:48:31 +02:00
|
|
|
$VENVDIR/bin/pip install pip --upgrade
|
2019-06-23 02:17:49 +05:30
|
|
|
|
|
|
|
# install IPA inside the virtual environment
|
2019-10-16 13:58:50 +02:00
|
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS $IPADIR --install-option="--install-scripts=/usr/local/bin/"
|
2019-06-23 02:17:49 +05:30
|
|
|
|
|
|
|
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)
|
2019-09-23 13:48:31 +02:00
|
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service
|
2019-06-23 02:17:49 +05:30
|
|
|
;;
|
|
|
|
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
|
2019-09-23 13:48:31 +02:00
|
|
|
cat /tmp/in_target.d/ipa-trusted-cert.pem >> $($VENVDIR/bin/python -c "import requests; print requests.certs.where()")
|
2019-06-23 02:17:49 +05:30
|
|
|
fi
|