Last active
August 29, 2015 14:23
-
-
Save sq3/5aa41301e553af9c30d9 to your computer and use it in GitHub Desktop.
TeamVault development environment - Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A quick and dirty ... | |
# _______________ __ ____ _____ __ ____ ______ | |
# /_ __/ ____/ | / |/ / | / / | / / / / / /_ __/ | |
# / / / __/ / /| | / /|_/ /| | / / /| |/ / / / / / / | |
# / / / /___/ ___ |/ / / / | |/ / ___ / /_/ / /___/ / | |
# /_/ /_____/_/ |_/_/ /_/ |___/_/ |_\____/_____/_/ | |
# | |
# ... development environment. | |
# You Can run this in a ubuntu docker container. | |
# Thx to vain - https://github.com/vain | |
# https://github.com/trehn/teamvault | |
/etc/init.d/rsyslog start | |
ip=$1 | |
# - Install packages - | |
apt_get() | |
{ | |
DEBIAN_FRONTEND=noninteractive \ | |
apt-get -qy -o Dpkg::Options::=--force-confold --no-install-recommends \ | |
"$@" | |
} | |
apt_get update | |
apt_get install \ | |
python3-setuptools git mercurial postgresql postgresql-contrib nginx \ | |
python3-pip python3.4-dev libffi-dev libpq-dev | |
apt_get build-dep python3-psycopg2 | |
pip3 install hg+https://bitbucket.org/kavanaugh_development/django-auth-ldap@python3-ldap | |
/etc/init.d/postgresql start | |
# - Setup DB - | |
cd / | |
sudo -u postgres psql -c "CREATE USER teamvault WITH SUPERUSER ENCRYPTED PASSWORD E'teamvault'" | |
sudo -u postgres createdb -O teamvault teamvault | |
# - Setup webserver - | |
cat >/etc/nginx/nginx.conf <<EOF | |
events { | |
worker_connections 1024; | |
} | |
http { | |
server { | |
listen 80; | |
location / { | |
proxy_pass http://localhost:8000; | |
proxy_set_header Host \$host; | |
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | |
} | |
} | |
} | |
EOF | |
service nginx restart | |
# - Install TeamVault - | |
cd /srv | |
git clone https://github.com/trehn/teamvault | |
cd / | |
pip3 install -e /srv/teamvault/ | |
teamvault setup | |
# - Configure TeamVault - | |
sed -i -r 's#^(base_url = ).*#\1http://'"$ip"'#' /etc/teamvault.cfg | |
sed -i -r 's/^(insecure_debug_mode = ).*$/\1enabled/' /etc/teamvault.cfg | |
teamvault upgrade | |
# - Create some users - | |
cat >/tmp/manage <<"EOF" | |
#!/usr/bin/env python3 | |
from os import environ | |
from os.path import dirname, join | |
from sys import argv | |
if __name__ == "__main__": | |
environ.setdefault("DJANGO_SETTINGS_MODULE", "teamvault.settings.local") | |
environ.setdefault("TEAMVAULT_CONFIG_FILE", join(dirname(dirname(__file__)), "teamvault.cfg")) | |
from django.core.management import execute_from_command_line | |
execute_from_command_line(argv) | |
EOF | |
DJANGO_SETTINGS_MODULE=teamvault.settings \ | |
TEAMVAULT_CONFIG_FILE=/etc/teamvault.cfg \ | |
python3 /tmp/manage shell <<"EOF" | |
from django.contrib.auth.models import User | |
user = User.objects.create_user('admin', 'admin@localhost.localdomain', 'admin') | |
user.is_staff = True | |
user.is_superuser = True | |
user.save() | |
for i in ['alice', 'bob', 'charly']: | |
user = User.objects.create_user(i, i + '@localhost.localdomain', i) | |
user.save() | |
EOF | |
# - Aaaaaaaaand we're done - | |
teamvault run | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment