#!/bin/bash
set -eux

# Mysqlclient-dev is needed for MySQL-python which os-svc-install installs.
install-packages python-pip libmysqlclient-dev

pip install -U distribute # required by virtualenv
# required to ensure clean distribute -> setuptools migration
pip install -U setuptools
pip install -U 'virtualenv==1.10.1'

install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-install /usr/local/bin/os-svc-install
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-daemon  /usr/local/bin/os-svc-daemon
install -m 0755 -o root -g root $(dirname $0)/../bin/os-db-create   /usr/local/bin/os-db-create
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable  /usr/local/bin/os-svc-enable
if [ "$(dib-init-system)" = "upstart" ] ; then
    install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable-upstart /usr/local/bin/os-svc-enable-upstart
    install -m 0644 -o root -g root $(dirname $0)/../upstart/os-svc-enable.conf /etc/init/os-svc-enable.conf
fi

install -m 0755 -o root -g root -d /opt/stack/venvs
