8f1c652862
OpenStack uses pbr for setuptools/build and version releases. As barbican looks towards incubation, migrate to being pbr based. Change-Id: I3c7a389596ca579a5613ea98b21cdc6967e49cc7
94 lines
1.7 KiB
Bash
Executable File
94 lines
1.7 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
|