diff options
author | ms <ms@taler.net> | 2021-11-14 15:27:03 +0100 |
---|---|---|
committer | ms <ms@taler.net> | 2021-11-14 15:27:03 +0100 |
commit | c0941eb1b9dba2e2321efe1a2f44ce4a529e7a03 (patch) | |
tree | a9f843829addbcca655cf7b222ccbb2ceec69d67 | |
parent | 8c21fd6b30a570979993dca3b8729e153b81dccb (diff) | |
download | deployment-c0941eb1b9dba2e2321efe1a2f44ce4a529e7a03.tar.gz deployment-c0941eb1b9dba2e2321efe1a2f44ce4a529e7a03.tar.bz2 deployment-c0941eb1b9dba2e2321efe1a2f44ce4a529e7a03.zip |
taler-local: launch euFin and donations
-rwxr-xr-x | bin/WIP/taler-local | 103 |
1 files changed, 83 insertions, 20 deletions
diff --git a/bin/WIP/taler-local b/bin/WIP/taler-local index d9d7378..bbb6abd 100755 --- a/bin/WIP/taler-local +++ b/bin/WIP/taler-local @@ -551,6 +551,10 @@ LOG_DIR = TALER_ROOT_DIR / "logs" UNIX_SOCKETS_DIR = TALER_ROOT_DIR / "sockets" REV_PROXY_NETLOC = "localhost:8080" REV_PROXY_PROTO = "http" +NEXUS_DB_FILE = "/tmp/nexus.sqlite" +SANDBOX_DB_FILE = "/tmp/sandbox.sqlite" +REV_PROXY_URL = f"{REV_PROXY_PROTO}://{REV_PROXY_NETLOC}" +SANDBOX_ADMIN_PASSWORD = "secret" @cli.command() def prepare(): @@ -725,11 +729,15 @@ def prepare(): CURRENCY = "EUR" WIRE_METHOD = "sepa" + # euFin URLs + SANDBOX_URL = REV_PROXY_URL + "/sandbox" + NEXUS_URL = REV_PROXY_URL + "/nexus" + # Filesystem's paths CFG_OUTDIR = TALER_ROOT_DIR / "config" TALER_RUNTIME_DIR = TALER_ROOT_DIR / "runtime" TALER_DATA_DIR = TALER_ROOT_DIR / "data" - SYSTEMD_UNIT_FILES_DIR = TALER_ROOT_DIR / "systemd-unit-files" + TALER_UNIT_FILES_DIR = TALER_ROOT_DIR / "systemd-unit-files" # IBANs IBAN_EXCHANGE = "EX00000000000000000000" @@ -744,16 +752,10 @@ def prepare(): # Credentials / API keys SANDBOX_ADMIN_USERNAME = "admin" - SANDBOX_ADMIN_PASSWORD = "secret" EXCHANGE_NEXUS_USERNAME = "exchange-nexus-user" EXCHANGE_NEXUS_PASSWORD = "exchange-nexus-password" FRONTENDS_API_TOKEN = "secret-token:secret" TALER_MERCHANT_TOKEN = "secret-token:secret" - - # URLs - REV_PROXY_URL = f"{REV_PROXY_PROTO}://{REV_PROXY_NETLOC}" - SANDBOX_URL = REV_PROXY_URL + "/sandbox" - NEXUS_URL = REV_PROXY_URL + "/nexus" # EBICS EBICS_HOST_ID = "ebicsDeployedHost" @@ -762,8 +764,6 @@ def prepare(): EBICS_URL = REV_PROXY_URL + "/sandbox/ebicsweb" # euFin - NEXUS_DB_FILE = "/tmp/nexus.sqlite" - SANDBOX_DB_FILE = "/tmp/sandbox.sqlite" EXCHANGE_BANK_ACCOUNT_NEXUS = "exchange-imported-account-nexus" EXCHANGE_BANK_ACCOUNT_SANDBOX = "exchange-account-sandbox" EXCHANGE_BANK_CONNECTION = "exchange-ebics-connection" @@ -962,7 +962,7 @@ def prepare(): obj.cfg_put("donations", "serve", "uwsgi") obj.cfg_put("donations", "uwsgi_serve", "unix") - obj.cfg_put("donations", "uwsgi_unixpath", str(unix_sockets_dir / "donations.Sock")) + obj.cfg_put("donations", "uwsgi_unixpath", str(unix_sockets_dir / "donations.sock")) obj.cfg_put("donations", "uwsgi_unixpath_mode", "660") obj.cfg_put("landing", "serve", "uwsgi") @@ -1577,17 +1577,17 @@ Logs: {rev_proxy.get_log_filename()}" rev_proxy.stop() print(" OK") - # Put SystemD unit files into the prepare folder. + print_nn("Installing SystemD unit files...") systemd_user_dir = Path.home() / ".config" / "systemd" / "user" if not systemd_user_dir.exists(): systemd_user_dir.mkdir(parents=True, exist_ok=True) - if not SYSTEMD_UNIT_FILES_DIR.exists(): - SYSTEMD_UNIT_FILES_DIR.mkdir(parents=True, exist_ok=True) + if not TALER_UNIT_FILES_DIR.exists(): + TALER_UNIT_FILES_DIR.mkdir(parents=True, exist_ok=True) # Exchange unit file. - exchange_unit = open(SYSTEMD_UNIT_FILES_DIR / "exchange.service", "w") + exchange_unit = open(TALER_UNIT_FILES_DIR / "exchange.service", "w") exchange_unit.write("[Unit]\n") exchange_unit.write('Description="Taler Exchange"\n') exchange_unit.write("[Service]\n") @@ -1595,7 +1595,7 @@ Logs: {rev_proxy.get_log_filename()}" f"ExecStart={TALER_PREFIX}/bin/taler-exchange-httpd -c {CFG_OUTDIR / 'taler.conf'}\n" ) # Exchange RSA helper unit file. - exchange_rsa_unit = open(SYSTEMD_UNIT_FILES_DIR / "exchange-secmod-rsa.service", "w") + exchange_rsa_unit = open(TALER_UNIT_FILES_DIR / "exchange-secmod-rsa.service", "w") exchange_rsa_unit.write("[Unit]\n") exchange_rsa_unit.write('Description="Taler Exchange RSA security module."\n') exchange_rsa_unit.write("[Service]\n") @@ -1604,7 +1604,7 @@ Logs: {rev_proxy.get_log_filename()}" ) exchange_rsa_unit.close() # Exchange EDDSA helper unit file. - exchange_eddsa_unit = open(SYSTEMD_UNIT_FILES_DIR / "exchange-secmod-eddsa.service", "w") + exchange_eddsa_unit = open(TALER_UNIT_FILES_DIR / "exchange-secmod-eddsa.service", "w") exchange_eddsa_unit.write("[Unit]\n") exchange_eddsa_unit.write('Description="Taler Exchange EDDSA security module."\n') exchange_eddsa_unit.write("[Service]\n") @@ -1613,7 +1613,7 @@ Logs: {rev_proxy.get_log_filename()}" ) exchange_eddsa_unit.close() # Merchant unit file. - merchant_unit = open(SYSTEMD_UNIT_FILES_DIR / "merchant-backend.service", "w") + merchant_unit = open(TALER_UNIT_FILES_DIR / "merchant-backend.service", "w") merchant_unit.write("[Unit]\n") merchant_unit.write('Description="Taler Merchant Backend"\n') merchant_unit.write("[Service]\n") @@ -1625,9 +1625,9 @@ Logs: {rev_proxy.get_log_filename()}" if os.environ.get("PGPORT"): exchange_unit.write(f"EnvironmentFile={systemd_user_dir / 'exchange.env'}") merchant_unit.write(f"EnvironmentFile={systemd_user_dir / 'merchant-backend.env'}") - with open(SYSTEMD_UNIT_FILES_DIR / "exchange.env", "w") as exchange_env: + with open(TALER_UNIT_FILES_DIR / "exchange.env", "w") as exchange_env: exchange_env.write(f"PGPORT={os.environ.get('PGPORT')}") - with open(SYSTEMD_UNIT_FILES_DIR / "merchant-backend.env", "w") as merchant_env: + with open(TALER_UNIT_FILES_DIR / "merchant-backend.env", "w") as merchant_env: merchant_env.write(f"PGPORT={os.environ.get('PGPORT')}") # Symlinking the environment files into the SystemD canonical user directory. if not os.path.islink(systemd_user_dir / "exchange.env"): @@ -1638,7 +1638,49 @@ Logs: {rev_proxy.get_log_filename()}" exchange_unit.close() merchant_unit.close() - # Symlinking the unit files into the canonical SystemD user directory. + # euFin unit files. + sandbox_unit = open(TALER_UNIT_FILES_DIR / "sandbox.service", "w") + sandbox_unit.write("[Unit]\n") + sandbox_unit.write('Description="euFin Sandbox"\n') + sandbox_unit.write("[Service]\n") + sandbox_unit.write( + f"ExecStart={TALER_PREFIX}/bin/libeufin-sandbox serve --with-unix-socket {UNIX_SOCKETS_DIR / 'sandbox.sock'}\n" + ) + sandbox_unit.write(f"EnvironmentFile={systemd_user_dir / 'sandbox.env'}") + sandbox_unit.close() + + nexus_unit = open(TALER_UNIT_FILES_DIR / "nexus.service", "w") + nexus_unit.write("[Unit]\n") + nexus_unit.write('Description="euFin Nexus"\n') + nexus_unit.write("[Service]\n") + nexus_unit.write( + f"ExecStart={TALER_PREFIX}/bin/libeufin-nexus serve --with-unix-socket {UNIX_SOCKETS_DIR / 'nexus.sock'}\n" + ) + nexus_unit.write(f"EnvironmentFile={systemd_user_dir / 'nexus.env'}") + nexus_unit.close() + # euFin env files. + sandbox_env = open(TALER_UNIT_FILES_DIR / "sandbox.env", "w") + sandbox_env.write(f"LIBEUFIN_SANDBOX_DB_CONNECTION=jdbc:sqlite:{SANDBOX_DB_FILE}\n") + sandbox_env.write(f"LIBEUFIN_SANDBOX_ADMIN_PASSWORD={SANDBOX_ADMIN_PASSWORD}") + sandbox_env.close() + nexus_env = open(TALER_UNIT_FILES_DIR / "nexus.env", "w") + nexus_env.write(f"LIBEUFIN_NEXUS_DB_CONNECTION=jdbc:sqlite:{NEXUS_DB_FILE}") + nexus_env.close() + + # Frontends + donations_unit = open(TALER_UNIT_FILES_DIR / "donations.service", "w") + donations_unit.write("[Unit]\n") + donations_unit.write("Description=Donation Website that accepts Taler payments.\n") + donations_unit.write("[Service]\n") + donations_unit.write( + f"ExecStart={TALER_PREFIX}/bin/taler-merchant-demos donations -c {CFG_OUTDIR / 'taler.conf'}\n" + ) + donations_unit.write(f"EnvironmentFile={systemd_user_dir / 'donations.env'}\n") + donations_unit.close() + donations_env = open(TALER_UNIT_FILES_DIR / "donations.env", "w") + donations_env.write(f"PATH={os.environ.get('PATH')}") + donations_env.close() + # Symlinking the unit (and env, for euFin) files into the canonical SystemD user directory. if not os.path.islink(systemd_user_dir / "exchange.service"): os.symlink(exchange_unit.name, systemd_user_dir / "exchange.service") if not os.path.islink(systemd_user_dir / "merchant-backend.service"): @@ -1647,6 +1689,21 @@ Logs: {rev_proxy.get_log_filename()}" os.symlink(exchange_rsa_unit.name, systemd_user_dir / "exchange-secmod-rsa.service") if not os.path.islink(systemd_user_dir / "exchange-secmod-eddsa.service"): os.symlink(exchange_eddsa_unit.name, systemd_user_dir / "exchange-secmod-eddsa.service") + if not os.path.islink(systemd_user_dir / "sandbox.service"): + os.symlink(sandbox_unit.name, systemd_user_dir / "sandbox.service") + if not os.path.islink(systemd_user_dir / "sandbox.env"): + os.symlink(sandbox_env.name, systemd_user_dir / "sandbox.env") + if not os.path.islink(systemd_user_dir / "nexus.service"): + os.symlink(nexus_unit.name, systemd_user_dir / "nexus.service") + if not os.path.islink(systemd_user_dir / "nexus.env"): + os.symlink(nexus_env.name, systemd_user_dir / "nexus.env") + if not os.path.islink(systemd_user_dir / "donations.service"): + os.symlink(donations_unit.name, systemd_user_dir / "donations.service") + if not os.path.islink(systemd_user_dir / "donations.env"): + os.symlink(donations_env.name, systemd_user_dir / "donations.env") + + print(" OK") + # more units here.. print_nn("Reload SystemD...") Command(["systemctl", "--user", "daemon-reload"]).run() @@ -1659,6 +1716,9 @@ def launch(): subprocess.run(["systemctl", "--user", "start", "exchange-secmod-rsa.service"], check=True) subprocess.run(["systemctl", "--user", "start", "exchange-secmod-eddsa.service"], check=True) subprocess.run(["systemctl", "--user", "start", "merchant-backend.service"], check=True) + subprocess.run(["systemctl", "--user", "start", "nexus.service"], check=True) + subprocess.run(["systemctl", "--user", "start", "sandbox.service"], check=True) + subprocess.run(["systemctl", "--user", "start", "donations.service"], check=True) rev_proxy = TalerReverseProxy( LOG_DIR, @@ -1674,6 +1734,9 @@ def launch(): ) # Stop with CTRL+C print_nn("Stopping the services...") + subprocess.run(["systemctl", "--user", "stop", "donations.service"], check=True) + subprocess.run(["systemctl", "--user", "stop", "nexus.service"], check=True) + subprocess.run(["systemctl", "--user", "stop", "sandbox.service"], check=True) subprocess.run(["systemctl", "--user", "stop", "merchant-backend.service"], check=True) subprocess.run(["systemctl", "--user", "stop", "exchange.service"], check=True) subprocess.run(["systemctl", "--user", "stop", "exchange-secmod-rsa.service"], check=True) |