diskimage-builder/elements/ironic-agent/install.d/ironic-agent-source-install/60-ironic-agent-install
Aparna cd66aebf40 Support to add certificate in ironic-agent
This commits provides support to add certificate while
building the image using ironic-agent element. The
certificate can be CA certificate or self-signed certificate.

The certificate is set to the environment variable
'DIB_IPA_CERT' which in turn is used by the ironic-agent
element while building the image.

Change-Id: I648f7934d4787dcc3030885cfca771b642a9595e
2016-04-14 13:42:36 +00:00

44 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
SCRIPTDIR=$(dirname $0)
IPADIR=/usr/share/ironic-python-agent
# create the virtual environment
virtualenv $IPADIR/venv
# install IPA inside the virtual environment
$IPADIR/venv/bin/pip install $IPADIR
# FIXME(lucasagomes): Figure out how we can use the "--install-option"
# parameter for pip install so we don't have to manually create a symlink
# create the launcher link so services can use it
ln -s $IPADIR/venv/bin/ironic-python-agent /usr/local/bin/ironic-python-agent
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 0755 ${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/server.pem ]; then
cat /tmp/in_target.d/server.pem >> $($IPADIR/venv/bin/python -c "import requests; print requests.certs.where()")
fi