taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

commit e37aa461c5b2c258af0d8c160a9078295fd6fd05
parent cc103cb587947056c3db371612eff8c929665690
Author: Florian Dold <florian.dold@gmail.com>
Date:   Thu, 10 Oct 2019 19:48:48 +0530

new taler-deployment in Python for bootstrapping

Diffstat:
Abin/taler-deployment | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+), 0 deletions(-)

diff --git a/bin/taler-deployment b/bin/taler-deployment @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 + +import click +import types +import os +import os.path +import subprocess +import time +from pathlib import Path + +activate_template = """\ +#!/bin/bash + +# Generated by taler-deployment-bootstrap + +function taler-config-generate () { + echo "Command disabled. Please use taler-deployment-config-generate instead." + return 1 +} +function taler-exchange-keyup () { + echo "Command disabled. Please use taler-deployment-keyup instead." +} + +export PATH="$HOME/deployment/bin:$HOME/local/bin:\$PATH" +export TALER_BOOTSTRAP_TIMESTAMP={timestamp} +export TALER_CHECKDB="postgres:///talercheck-$USER" +export TALER_CONFIG_CURRENCY={currency} +export TALER_ENV_NAME={envname} +export TALER_ENV_URL_INTRO="https://{envname}.taler.net/" +export TALER_ENV_URL_BANK="https://bank.{envname}.taler.net/" +export TALER_ENV_URL_MERCHANT_BLOG="https://shop.{envname}.taler.net/" +export TALER_ENV_URL_MERCHANT_DONATIONS="https://donations.{envname}.taler.net/" +export TALER_ENV_URL_MERCHANT_SURVEY="https://survey.{envname}.taler.net/" +export TALER_ENV_URL_AUDITOR="https://auditor.{envname}.taler.net/" +export TALER_ENV_URL_BACKOFFICE="https://backoffice.{envname}.taler.net/" +""" + + +@click.group() +def cli(): + pass + + +@cli.command() +@click.argument("envname", type=click.Choice(["test", "int", "demo"])) +def bootstrap(envname): + """Bootstrap a GNU Taler deployment from the deploymen.git repository""" + + home = Path.home() + + # read Python-style config + cfg = types.ModuleType(name) + cfgtext = (home / "envcfg.py").read_text() + exec(cfgtext, module.__dict__) + + repos = [ + ("gnunet", "git://gnunet.org/gnunet.git"), + ("libmicrohttps", "gnunet.org/libmicrohttpd.git"), + ("twister", "git://git.taler.net/twister"), + ("bank", "git://git.taler.net/bank"), + ("merchant", "git://git.taler.net/merchant"), + ("landing", "git://git.taler.net/landing"), + ("exchange", "git://git.taler.net/exchange"), + ("donations", "git://git.taler.net/donations"), + ("blog", "git://git.taler.net/blog"), + ("survey", "git://git.taler.net/survey"), + ("backoffice", "git://git.taler.net/backoffice"), + ] + + for (r_name, r_url) in repos: + r_dir = home / "sources" / r_name + if not r_dir.exists(): + r_dir.mkdir(parents=True, exist_ok=True) + subprocess.run(["git", "-C", r_dir.as_posix(), "clone", r_url], check=True) + tag = getattr(cfg, "tag_" + r_name) + subprocess.run(["git", "-C", r_dir.as_posix(), "fetch"], check=True) + subprocess.run( + ["git", "-C", r_dir.as_posix(), "checkout", "-q", "-f", tag, "--"], + check=True, + ) + + with (home / "activate").open("w") as f: + f.write(activate_template.format(envname=envname, timestamp=str(time.time()))) + + (home / "sockets").mkdir(parents=True, exist_ok=True) + (home / "taler-data").mkdir(parents=True, exist_ok=True) + + if envname == "test": + bb_dir = home / "bb-worker" + if not bb_dir.exists(): + subprocess.run( + [ + "buildbot-worker", + "create-worker", + "--umask=0o22", + bb_dir.as_posix(), + "localhost:9989", + "test-worker", + "test-pass", + ], + check=True, + ) + print("Bootstrap finished.") + print("Please source the ~/activate file before proceeding.") + + +if __name__ == "__main__": + cli()