Files
barbican/bin/barbican.sh
jfwood 2fca4f68c3 Fix file copy bug with the barbican installer.
The barbican installer (in bin/barbican.sh) is not copying files correctly
to user's environments, which breaks the install. This commit fixes that
issue.

Change-Id: I5fad5332bd329a4ca13b5843127fd6dc033ad45f
2014-01-03 16:02:27 -06:00

94 lines
1.8 KiB
Bash
Executable File

#!/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 requirements.txt
pip install -r test-requirements.txt
# 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