diff --git a/README.md b/README.md index e405ca334..25a2e4bda 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Additional documentation can be found on the [Github Wiki](https://github.com/cl ## 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? diff --git a/bin/barbican-all b/bin/barbican-all deleted file mode 100755 index 111cc5acd..000000000 --- a/bin/barbican-all +++ /dev/null @@ -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 diff --git a/bin/barbican.sh b/bin/barbican.sh new file mode 100755 index 000000000..434745aec --- /dev/null +++ b/bin/barbican.sh @@ -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 diff --git a/rpmbuild/SPECS/barbican.spec b/rpmbuild/SPECS/barbican.spec index a10649908..9c48bef3f 100644 --- a/rpmbuild/SPECS/barbican.spec +++ b/rpmbuild/SPECS/barbican.spec @@ -79,7 +79,7 @@ Barbican Key Manager API daemon %defattr(-,root,root) %verify(not md5 size mtime) %attr(0750, barbican,root) /var/log/barbican/barbican-api.log /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/barbican/* diff --git a/setup.py b/setup.py index 37c61b825..f2db1d56e 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,7 @@ setup( 'Programming Language :: Python :: 2.7', 'Environment :: No Input/Output (Daemon)', ], - scripts=['bin/barbican-all', 'bin/barbican-worker.py'], + scripts=['bin/barbican.sh', 'bin/barbican-worker.py'], py_modules=[], entry_points=""" [barbican.crypto.plugin]