Last active
August 29, 2015 14:12
-
-
Save vain/3e11039eb490ce519e5b to your computer and use it in GitHub Desktop.
Quick and dirty teamvault development environment on Arch Linux using overqemu
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
for i in {1..250}; do curl -X POST -H 'Content-Type: application/json' --user bob:bob --data-binary '{"allowed_groups": [], "allowed_users": ["bob"], "name": "apitest '"$i"'", "password": "huch '"$i"'"}' 'http://10.33.20.2/api/secrets/'; done |
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 on Arch Linux using overqemu. | |
# https://github.com/trehn/teamvault | |
# https://github.com/vain/bin-pub/blob/master/overqemu | |
# Run overqemu: | |
# | |
# $ overqemu -T 20 | |
# | |
# Then run this script inside of it: | |
# | |
# $ scp teamvault-envstrap overqemu20: && ssh -t overqemu20 'bash teamvault-envstrap 20' | |
# | |
# Once it's finished, open "http://10.33.20.2" on your host. | |
slot=$1 | |
[[ -z $slot ]] && { echo "Usage: $0 <slot>" >&2; exit 1; } | |
ip link set dev eth1 up | |
ip a add 10.33.$slot.2/24 dev eth1 | |
pacman --noconfirm -Syu python-pip git mercurial postgresql nginx | |
cd / | |
sudo -u postgres initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data' | |
systemctl start postgresql | |
echo "CREATE ROLE teamvault UNENCRYPTED PASSWORD 'teamvault' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;" | sudo -u postgres psql | |
sudo -u postgres createdb teamvault | |
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 | |
systemctl start nginx | |
cd /srv | |
git clone https://github.com/trehn/teamvault | |
cd teamvault | |
python setup.py develop | |
pip install --upgrade --force-reinstall djangorestframework # FIXME | |
pip install hg+https://bitbucket.org/kavanaugh_development/django-auth-ldap@python3-ldap | |
teamvault setup | |
teamvault upgrade | |
sed -i -r 's#^(base_url = ).*#\1http://10.33.'"$slot"'.2#' /etc/teamvault.cfg | |
TEAMVAULT_CONFIG_FILE=/etc/teamvault.cfg python src/manage_local.py shell <<"EOF" | |
from django.contrib.auth.models import User | |
user = User.objects.create_user('admin', '[email protected]', '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 | |
cat <<"EOF" | |
_ _ | |
___ ___| |_ _ _ _ __ __| | ___ _ __ ___ | |
/ __|/ _ \ __| | | | '_ \ / _` |/ _ \| '_ \ / _ \ | |
\__ \ __/ |_| |_| | |_) | | (_| | (_) | | | | __/ | |
|___/\___|\__|\__,_| .__/ \__,_|\___/|_| |_|\___| | |
|_| | |
Launching teamvault ... | |
EOF | |
teamvault run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment