Add a better installer for local Barbican application instances.
The current local installer (bin/barbican-all) requires that users perform several steps before hand. The new installer seeks to minimize the amount of manual steps needed. Change-Id: Ie5d74331028fa7c463f53bed92a504771c09a385 Implements: blueprint add-local-installer-script
This commit is contained in:
parent
ced5057abb
commit
fc155c2f72
@ -12,7 +12,7 @@ Additional documentation can be found on the [Github Wiki](https://github.com/cl
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
* [Please visit our wiki home page for details](https://github.com/cloudkeep/barbican/wiki)
|
* [Please visit our Getting Started wiki page for details](https://github.com/cloudkeep/barbican/wiki/Barbican-Getting-Started-Guide)
|
||||||
|
|
||||||
|
|
||||||
## Why Should You Use Barbican?
|
## Why Should You Use Barbican?
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# barbican-api - Script run Cloudkeep's Barbican API app.
|
|
||||||
|
|
||||||
PKG=barbican
|
|
||||||
|
|
||||||
# For local development, set VENV_PYTHON equal to the path to your virtual environment's site-packages location
|
|
||||||
VENV=${VENV:-.venv}
|
|
||||||
VENV_HOME=${VENV_HOME:-$PWD}
|
|
||||||
VENV_PYTHON=$VENV_HOME/$VENV/lib/python2.7/site-packages
|
|
||||||
|
|
||||||
PKG_DIR=/etc/$PKG
|
|
||||||
CONF_FILE=$PKG_DIR/barbican-api.conf
|
|
||||||
POLICY_FILE=$PKG_DIR/policy.json
|
|
||||||
SIGNING_DIR=$PKG_DIR/cache/
|
|
||||||
OPTS='--daemonize /var/log/barbican/uwsgi.log'
|
|
||||||
|
|
||||||
# Configure for a local deployment environment:
|
|
||||||
if [ ! -f $CONF_FILE ];
|
|
||||||
then
|
|
||||||
echo 'Running locally...'
|
|
||||||
|
|
||||||
PKG_DIR=$PWD/etc/$PKG
|
|
||||||
CONF_FILE=./etc/$PKG/barbican-api.conf
|
|
||||||
PYTHONPATH=$VENV_PYTHON:$PYTHONPATH
|
|
||||||
OPTS='-H '$VENV_HOME/$VENV' --stats :9314'
|
|
||||||
|
|
||||||
# Copy conf file to home directory so oslo.config can find it
|
|
||||||
LOCAL_CONF_FILE=~/barbican-api.conf
|
|
||||||
if [ ! -f $LOCAL_CONF_FILE ];
|
|
||||||
then
|
|
||||||
cp ./etc/$PKG/barbican-api.conf ~
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: This is breaking deployment...need to analyze.
|
|
||||||
#if [ ! -f $POLICY_FILE ];
|
|
||||||
#then
|
|
||||||
# LOCAL_POLICY_FILE=./etc/$PKG/policy.json
|
|
||||||
# mkdir -p $PKG_DIR
|
|
||||||
# sudo cp $LOCAL_POLICY_FILE POLICY_FILE
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#if [ ! -f $SIGNING_DIR ];
|
|
||||||
#then
|
|
||||||
# echo "making "$SIGNING_DIR
|
|
||||||
# sudo mkdir -p $SIGNING_DIR
|
|
||||||
#fi
|
|
||||||
|
|
||||||
echo 'Running Barbican uWSGI Emperor '$PKG_DIR/vassals
|
|
||||||
echo 'Executing uwsgi with these options: '$PKG_DIR/vassals' '$OPTS
|
|
||||||
uwsgi --master --emperor $PKG_DIR/vassals $OPTS
|
|
93
bin/barbican.sh
Executable file
93
bin/barbican.sh
Executable file
@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CONFIG_DIR=/etc/barbican
|
||||||
|
DB_DIR=/var/lib/barbican
|
||||||
|
VENV_DIR=${BARBICAN_VENV:-~/.pyenv/versions/$PYENV_VERSION}
|
||||||
|
|
||||||
|
LOCAL_CONFIG_DIR=./etc/barbican
|
||||||
|
if [ ! -d $LOCAL_CONFIG_DIR ];
|
||||||
|
then
|
||||||
|
LOCAL_CONFIG_DIR=../etc/barbican
|
||||||
|
fi
|
||||||
|
LOCAL_CONFIG=$LOCAL_CONFIG_DIR/barbican-api.conf
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
echo 'DIR: '$DIR
|
||||||
|
|
||||||
|
start_barbican()
|
||||||
|
{
|
||||||
|
# Start barbican server up.
|
||||||
|
# Note: Add ' --stats :9314' to run a stats server on port 9314
|
||||||
|
echo "Starting barbican..."
|
||||||
|
uwsgi --master --emperor $CONFIG_DIR/vassals -H $VENV_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_barbican()
|
||||||
|
{
|
||||||
|
echo "Stopping barbican..."
|
||||||
|
killall -KILL uwsgi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_barbican()
|
||||||
|
{
|
||||||
|
# Copy conf file to home directory so oslo.config can find it
|
||||||
|
cp $LOCAL_CONFIG ~
|
||||||
|
|
||||||
|
# Copy the other config files to the /etc location
|
||||||
|
if [ ! -d $CONFIG_DIR ];
|
||||||
|
then
|
||||||
|
sudo mkdir -p $CONFIG_DIR
|
||||||
|
sudo chown $USER $CONFIG_DIR
|
||||||
|
fi
|
||||||
|
cp -rf $LOCAL_CONFIG_DIR/ $CONFIG_DIR
|
||||||
|
|
||||||
|
# Create a SQLite db location.
|
||||||
|
if [ ! -d $DB_DIR ];
|
||||||
|
then
|
||||||
|
sudo mkdir -p $DB_DIR
|
||||||
|
sudo chown $USER $DB_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
|
pip install -r tools/pip-requires
|
||||||
|
pip install -r tools/test-requires
|
||||||
|
|
||||||
|
# Install uWSGI
|
||||||
|
pip install uwsgi
|
||||||
|
|
||||||
|
# Install source code into the Python path as if packaged.
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
# If using pyenv, rehash now.
|
||||||
|
hash pyenv &> /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
pyenv rehash
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
nosetests
|
||||||
|
|
||||||
|
start_barbican
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
install)
|
||||||
|
install_barbican
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
start_barbican
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop_barbican
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop_barbican
|
||||||
|
sleep 5
|
||||||
|
start_barbican
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: barbican.sh {install|start|stop|restart}"
|
||||||
|
exit 1
|
||||||
|
esac
|
@ -79,7 +79,7 @@ Barbican Key Manager API daemon
|
|||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%verify(not md5 size mtime) %attr(0750, barbican,root) /var/log/barbican/barbican-api.log
|
%verify(not md5 size mtime) %attr(0750, barbican,root) /var/log/barbican/barbican-api.log
|
||||||
/etc/logrotate.d/barbican-api
|
/etc/logrotate.d/barbican-api
|
||||||
%attr(0755,root,root) /usr/bin/barbican-all
|
%attr(0755,root,root) /usr/bin/barbican.sh
|
||||||
%config(noreplace) /etc/init/barbican-api.conf
|
%config(noreplace) /etc/init/barbican-api.conf
|
||||||
%config(noreplace) /etc/barbican/*
|
%config(noreplace) /etc/barbican/*
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -71,7 +71,7 @@ setup(
|
|||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Environment :: No Input/Output (Daemon)',
|
'Environment :: No Input/Output (Daemon)',
|
||||||
],
|
],
|
||||||
scripts=['bin/barbican-all', 'bin/barbican-worker.py'],
|
scripts=['bin/barbican.sh', 'bin/barbican-worker.py'],
|
||||||
py_modules=[],
|
py_modules=[],
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[barbican.crypto.plugin]
|
[barbican.crypto.plugin]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user