summaryrefslogtreecommitdiff
path: root/bin/taler-deployment-config-generate
diff options
context:
space:
mode:
Diffstat (limited to 'bin/taler-deployment-config-generate')
-rwxr-xr-xbin/taler-deployment-config-generate285
1 files changed, 0 insertions, 285 deletions
diff --git a/bin/taler-deployment-config-generate b/bin/taler-deployment-config-generate
deleted file mode 100755
index 0101d78..0000000
--- a/bin/taler-deployment-config-generate
+++ /dev/null
@@ -1,285 +0,0 @@
-#!/usr/bin/env python3
-import click
-import sys
-from collections import OrderedDict
-import json
-import os
-import urllib.parse
-import stat
-from taler_urls import get_urls, get_port
-
-
-class ConfigFile:
- def __init__(self, envname, currency, exchange_pub, filename):
- self.sections = OrderedDict()
- self.envname = envname
- self.filename = filename
- self.currency = currency
- self.exchange_pub = exchange_pub
-
- def destroy(self):
- del self.sections
- self.sections = OrderedDict()
-
- def cfg_put(self, section_name, key, value):
- s = self.sections[section_name] = self.sections.get(section_name, OrderedDict())
- s[key] = value
-
- def cfg_write(self, outdir):
-
- if outdir:
- fstream = open(os.path.join(outdir, self.filename), "w")
- else:
- fstream = open(sys.stdout)
-
- for section_name, section in self.sections.items():
- fstream.write("[" + section_name + "]" + "\n")
- for key, value in section.items():
- fstream.write(key + " = " + value + "\n")
- fstream.write("\n")
- fstream.close()
-
-
-def coin(
- obj,
- name,
- value,
- d_withdraw="3 years",
- d_spend="5 years",
- d_legal="10 years",
- f_withdraw="0.01",
- f_deposit="0.01",
- f_refresh="0.01",
- f_refund="0.01",
- rsa_keysize="2048",
-):
- sec = "coin_" + obj.currency + "_" + name
- obj.cfg_put(sec, "value", obj.currency + ":" + value)
- obj.cfg_put(sec, "duration_withdraw", d_withdraw)
- obj.cfg_put(sec, "duration_spend", d_spend)
- obj.cfg_put(sec, "duration_legal", d_legal)
- obj.cfg_put(sec, "fee_withdraw", obj.currency + ":" + f_withdraw)
- obj.cfg_put(sec, "fee_refresh", obj.currency + ":" + f_refresh)
- obj.cfg_put(sec, "fee_refund", obj.currency + ":" + f_refund)
- obj.cfg_put(sec, "fee_deposit", obj.currency + ":" + f_deposit)
- obj.cfg_put(sec, "rsa_keysize", rsa_keysize)
-
-
-def config(obj):
- urls = get_urls(obj.envname)
- obj.cfg_put("paths", "TALER_DATA_HOME", "${HOME}/taler-data")
- obj.cfg_put("paths", "TALER_RUNTIME_DIR", "${HOME}/taler-runtime")
- obj.cfg_put("taler", "CURRENCY", obj.currency)
- obj.cfg_put("taler", "CURRENCY_ROUND_UNIT", f"{obj.currency}:0.01")
- if obj.envname != "local":
- obj.cfg_put("bank", "serve", "uwsgi")
- obj.cfg_put("bank", "uwsgi_serve", "unix")
- obj.cfg_put("bank", "uwsgi_unixpath", "$HOME/sockets/bank.uwsgi")
- obj.cfg_put("bank", "uwsgi_unixpath_mode", "660")
- else:
- obj.cfg_put("bank", "serve", "http")
- obj.cfg_put("bank", "http_port", get_port(urls["bank"]))
-
- obj.cfg_put("bank", "database", "taler" + obj.envname)
- obj.cfg_put("bank", "max_debt", "%s:500.0" % obj.currency)
- obj.cfg_put("bank", "max_debt_bank", "%s:1000000000.0" % obj.currency)
- obj.cfg_put("bank", "allow_registrations", "YES")
- obj.cfg_put("bank", "base_url", urls["bank"])
- obj.cfg_put("bank", "database", "postgres:///taler{}".format(obj.envname))
- obj.cfg_put("bank", "suggested_exchange", urls["exchange"])
-
- obj.cfg_put("bank-admin", "uwsgi_serve", "unix")
- obj.cfg_put("bank-admin", "uwsgi_unixpath", "$HOME/sockets/bank-admin.uwsgi")
- obj.cfg_put("bank-admin", "uwsgi_unixpath_mode", "660")
-
- obj.cfg_put("donations", "serve", "uwsgi")
- obj.cfg_put("donations", "uwsgi_serve", "unix")
- obj.cfg_put("donations", "uwsgi_unixpath", "$HOME/sockets/donations.uwsgi")
- obj.cfg_put("donations", "uwsgi_unixpath_mode", "660")
-
- obj.cfg_put("landing", "serve", "uwsgi")
- obj.cfg_put("landing", "uwsgi_serve", "unix")
- obj.cfg_put("landing", "uwsgi_unixpath", "$HOME/sockets/landing.uwsgi")
- obj.cfg_put("landing", "uwsgi_unixpath_mode", "660")
-
- obj.cfg_put("blog", "serve", "uwsgi")
- obj.cfg_put("blog", "uwsgi_serve", "unix")
- obj.cfg_put("blog", "uwsgi_unixpath", "$HOME/sockets/shop.uwsgi")
- obj.cfg_put("blog", "uwsgi_unixpath_mode", "660")
-
- obj.cfg_put("survey", "serve", "uwsgi")
- obj.cfg_put("survey", "uwsgi_serve", "unix")
- obj.cfg_put("survey", "uwsgi_unixpath", "$HOME/sockets/survey.uwsgi")
- obj.cfg_put("survey", "uwsgi_unixpath_mode", "660")
- obj.cfg_put("survey", "bank_password", "x")
-
- obj.cfg_put("backoffice-all", "backend", urls["merchant_backend"])
-
- # Keep only one back-office service for all instances, for simplicity.
- obj.cfg_put("backoffice-all", "uwsgi_serve", "unix")
- obj.cfg_put("backoffice-all", "uwsgi_unixpath_mode", "660")
- obj.cfg_put("backoffice-all", "uwsgi_unixpath", "$HOME/sockets/backoffice.uwsgi")
- obj.cfg_put("backoffice-all", "instances", "FSF default Tor")
-
- if obj.envname != "local":
- obj.cfg_put("merchant", "serve", "unix")
- obj.cfg_put("merchant", "unixpath", "$HOME/sockets/merchant.http")
- else:
- obj.cfg_put("merchant", "serve", "tcp")
- obj.cfg_put("merchant", "port", get_port(urls["merchant_backend"]))
-
- obj.cfg_put("merchant", "wire_transfer_delay", "0 s")
- obj.cfg_put("merchant", "default_max_wire_fee", obj.currency + ":" + "0.01")
- obj.cfg_put("merchant", "default_max_deposit_fee", obj.currency + ":" + "0.05")
- obj.cfg_put(
- "merchantdb-postgres", "config", "postgres:///taler{}".format(obj.envname)
- )
-
- obj.cfg_put("frontends", "backend", urls["merchant_backend"])
-
- obj.cfg_put(
- "merchant-exchange-{}".format(obj.currency), "master_key", obj.exchange_pub
- )
- obj.cfg_put("merchant-exchange-{}".format(obj.currency), "currency", obj.currency)
-
- obj.cfg_put(
- "merchant-exchange-{}".format(obj.currency),
- "exchange_base_url",
- urls["exchange"],
- )
-
- obj.cfg_put("auditor", "serve", "unix")
- obj.cfg_put("auditor", "base_url", urls["auditor"])
- obj.cfg_put("auditor", "auditor_url", urls["auditor"])
- obj.cfg_put("auditor", "unixpath", "$HOME/sockets/auditor.http")
- obj.cfg_put("auditor", "tiny_amount", obj.currency + ":0.01")
-
- obj.cfg_put("taler-exchange-secmod-eddsa", "unixpath", "$HOME/sockets/taler-exchange-secmod-eddsa.sock")
- obj.cfg_put("taler-exchange-secmod-rsa", "unixpath", "$HOME/sockets/taler-exchange-secmod-rsa.sock")
- obj.cfg_put("taler-exchange-secmod-rsa", "sm_priv_key", "${TALER_DATA_HOME}/taler-exchange-secmod-rsa/secmod-private-key")
-
- obj.cfg_put("exchange", "base_url", urls["exchange"])
-
- if obj.envname != "local":
- obj.cfg_put("exchange", "serve", "unix")
- obj.cfg_put("exchange", "unixpath", "$HOME/sockets/exchange.http")
- else:
- obj.cfg_put("exchange", "serve", "tcp")
- obj.cfg_put("exchange", "port", get_port(urls["exchange"]))
-
- obj.cfg_put("exchange", "master_public_key", obj.exchange_pub)
- obj.cfg_put("exchange", "terms_etag", "0")
- obj.cfg_put("exchange", "terms_dir", "$HOME/local/share/taler-exchange/tos")
- obj.cfg_put("exchange", "privacy_etag", "0")
- obj.cfg_put("exchange", "privacy_dir", "$HOME/local/share/taler-exchange/pp")
-
-
- obj.cfg_put(
- "exchangedb-postgres", "db_conn_str", "postgres:///taler{}".format(obj.envname)
- )
- obj.cfg_put(
- "exchangedb-postgres", "config", "postgres:///taler{}".format(obj.envname)
- )
- obj.cfg_put(
- "auditordb-postgres", "db_conn_str", "postgres:///taler{}".format(obj.envname)
- )
- obj.cfg_put(
- "auditordb-postgres", "config", "postgres:///taler{}".format(obj.envname)
- )
-
- bank_acct_url = "{}taler-wire-gateway/Exchange/".format(urls["bank"])
-
- obj.cfg_put(
- "exchange-account-1", "payto_uri", "{}Exchange".format(urls["talerbank_payto"])
- )
- obj.cfg_put("exchange-account-1", "enable_debit", "yes")
- obj.cfg_put("exchange-account-1", "enable_credit", "yes")
- obj.cfg_put("exchange-accountcredentials-1", "wire_gateway_auth_method", "basic")
- obj.cfg_put("exchange-accountcredentials-1", "wire_gateway_url", bank_acct_url)
- obj.cfg_put("exchange-accountcredentials-1", "username", "Exchange")
- obj.cfg_put("exchange-accountcredentials-1", "password", "x")
-
- obj.cfg_put(
- "merchant-account-merchant",
- "payto_uri",
- "{}Tutorial".format(urls["talerbank_payto"]),
- )
- obj.cfg_put(
- "merchant-account-merchant",
- "wire_response",
- "${TALER_DATA_HOME}/merchant/wire/merchant.json",
- )
- obj.cfg_put("merchant-account-merchant", "wire_file_mode", "770")
-
- # The following block should be obsoleted by the new API to configure instances.
- merchant_instance_names = ("default", "Tor", "GNUnet", "Taler", "FSF", "Tutorial")
- for mi in merchant_instance_names:
- obj.cfg_put("merchant-account-merchant", f"HONOR_{mi}", "YES")
- obj.cfg_put("merchant-account-merchant", f"ACTIVE_{mi}", "YES")
-
- coin(obj, "ct_10", "0.10")
- coin(obj, "1", "1")
- coin(obj, "2", "2")
- coin(obj, "5", "5")
- coin(obj, "10", "10")
- coin(obj, "1000", "1000")
-
-
-@click.command()
-@click.option("--currency", default="KUDOS")
-@click.option("--envname", default="demo")
-@click.option("--outdir", required=True)
-@click.option("--exchange-pub", required=True)
-# Expected to contain already the 'secret-token:' scheme.
-@click.option("--frontends-apitoken", required=True)
-def main(currency, envname, outdir, exchange_pub, frontends_apitoken):
-
- if envname not in ("tanker", "demo", "test", "int", "euro", "chf", "local"):
- print("envname (%s) not demo/test/int, aborting config generation" % envname)
- return
-
- config_files = []
-
- mc = ConfigFile(envname, currency, exchange_pub, "taler.conf")
- mc.cfg_put("frontends", "backend_apikey", f"{frontends_apitoken}")
- config(mc)
- config_files.append(mc)
-
- urls = get_urls(envname)
-
- sc = ConfigFile(envname, currency, exchange_pub, "sync.conf")
- sc.cfg_put("taler", "currency", currency)
- sc.cfg_put("sync", "serve", "unix")
- sc.cfg_put("sync", "unixpath", "$HOME/sockets/sync.http")
- sc.cfg_put("sync", "apikey", f"Bearer {frontends_apitoken}")
- sc.cfg_put("sync", "annual_fee", f"{currency}:0.1")
- sc.cfg_put("sync", "fulfillment_url", "taler://fulfillment-success/")
- sc.cfg_put("sync", "payment_backend_url", urls["merchant_backend"] + "instances/Taler/")
- sc.cfg_put("syncdb-postgres", "config", f"postgres:///taler{envname}")
- config_files.append(sc)
-
- ac = ConfigFile(envname, currency, exchange_pub, "anastasis.conf")
- ac.cfg_put("taler", "currency", currency)
- ac.cfg_put("anastasis", "serve", "unix")
- ac.cfg_put("anastasis", "business_name", f"GNU Taler Demo Anastasis Provider")
- ac.cfg_put("anastasis", "unixpath", "$HOME/sockets/anastasis.http")
- ac.cfg_put("anastasis", "annual_fee", f"{currency}:0")
- ac.cfg_put("anastasis", "question_cost", f"{currency}:0")
- ac.cfg_put("anastasis", "insurance", f"{currency}:0")
- ac.cfg_put("anastasis", "truth_upload_fee", f"{currency}:0")
- ac.cfg_put("anastasis", "fulfillment_url", "taler://fulfillment-success/")
- ac.cfg_put("anastasis", "server_salt", "kreb3ia9dmj43gfa")
- ac.cfg_put("stasis-postgres", "config", f"postgres:///taler{envname}")
- ac.cfg_put("anastasis-merchant-backend", "payment_backend_url", urls["merchant_backend"] + "instances/anastasis/")
- ac.cfg_put("anastasis-merchant-backend", "api_key", f"Bearer {frontends_apitoken}")
- ac.cfg_put("authorization-question", "cost", f"{currency}:0")
- ac.cfg_put("authorization-question", "enabled", "yes")
- config_files.append(ac)
-
- assert 0 < len(config_files)
- for obj in config_files:
- obj.cfg_write(outdir)
-
-
-if __name__ == "__main__":
- main()