mirror of
https://github.com/chatmail/relay.git
synced 2026-05-13 17:34:38 +00:00
snap
This commit is contained in:
@@ -4,6 +4,7 @@ along with command line option and subcommand parsing.
|
||||
"""
|
||||
import importlib.resources
|
||||
import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -11,7 +12,7 @@ from pathlib import Path
|
||||
import iniconfig
|
||||
|
||||
from termcolor import colored
|
||||
from chatmaild.config import read_config
|
||||
from chatmaild.config import read_config, write_initial_config
|
||||
|
||||
|
||||
class Out:
|
||||
@@ -52,6 +53,7 @@ def add_subcommand(subparsers, func):
|
||||
doc = func.__doc__.strip()
|
||||
p = subparsers.add_parser(name, description=doc, help=doc)
|
||||
p.set_defaults(func=func)
|
||||
add_config_option(p)
|
||||
return p
|
||||
|
||||
|
||||
@@ -63,15 +65,13 @@ def get_parser():
|
||||
)
|
||||
|
||||
init_parser = add_subcommand(subparsers, init_cmd)
|
||||
add_config_option(init_parser)
|
||||
init_parser.add_argument(
|
||||
"chatmail_domain",
|
||||
action="store",
|
||||
help="fully qualified DNS domain name for your chatmail instance",
|
||||
)
|
||||
|
||||
install_parser = add_subcommand(subparsers, install_cmd)
|
||||
add_config_option(install_parser)
|
||||
install_parser = add_subcommand(subparsers, run_cmd)
|
||||
install_parser.add_argument(
|
||||
"--dry-run",
|
||||
dest="dry_run",
|
||||
@@ -80,46 +80,24 @@ def get_parser():
|
||||
)
|
||||
|
||||
add_subcommand(subparsers, webdev_cmd)
|
||||
|
||||
add_subcommand(subparsers, test_cmd)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def write_initial_config(inipath, mailname, out):
|
||||
inidir = importlib.resources.files(__package__).joinpath("ini")
|
||||
content = inidir.joinpath("chatmail.ini.f").read_text().format(mailname=mailname)
|
||||
if mailname.endswith(".testrun.org"):
|
||||
override_inipath = inidir.joinpath("override-testrun.ini")
|
||||
privacy = iniconfig.IniConfig(override_inipath)["privacy"]
|
||||
lines = []
|
||||
for line in content.split("\n"):
|
||||
for key, value in privacy.items():
|
||||
value_lines = value.strip().split("\n")
|
||||
if not line.startswith(f"{key} =") or not value_lines:
|
||||
continue
|
||||
if len(value_lines) == 1:
|
||||
lines.append(f"{key} = {value}")
|
||||
else:
|
||||
lines.append(f"{key} =")
|
||||
for vl in value_lines:
|
||||
lines.append(f" {vl}")
|
||||
break
|
||||
else:
|
||||
lines.append(line)
|
||||
content = "\n".join(lines)
|
||||
|
||||
inipath.write_text(content)
|
||||
out(f"written {inipath} for chatmail domain {mailname}")
|
||||
|
||||
|
||||
def init_cmd(args, out):
|
||||
"""Initialize chatmail config file."""
|
||||
if args.chatmail_ini.exists():
|
||||
out.red(f"Path exists, not modifying: {args.chatmail_ini}")
|
||||
raise SystemExit(1)
|
||||
write_initial_config(args.chatmail_ini, args.chatmail_domain, out)
|
||||
write_initial_config(args.chatmail_ini, args.chatmail_domain)
|
||||
out.green(f"created config file for {args.chatmail_domain} in {args.chatmail_ini}")
|
||||
|
||||
|
||||
def install_cmd(args, out):
|
||||
"""Install or update chatmail services on the remote server."""
|
||||
def run_cmd(args, out):
|
||||
"""Deploy chatmail services on the remote server."""
|
||||
import pyinfra
|
||||
|
||||
try:
|
||||
@@ -147,6 +125,17 @@ def webdev_cmd(args, out):
|
||||
main()
|
||||
|
||||
|
||||
def test_cmd(args, out):
|
||||
"""run Run web development loop for static local web pages."""
|
||||
|
||||
tox = shutil.which("tox")
|
||||
subprocess.check_call([tox, "-c", "chatmaild"])
|
||||
subprocess.check_call([tox, "-c", "deploy-chatmail"])
|
||||
|
||||
pytest_path = shutil.which("tox")
|
||||
subprocess.check_call([pytest_path, "tests/online", "-rs", "-x", "-vrx", "--durations=5"])
|
||||
|
||||
|
||||
def main(args=None):
|
||||
"""Provide main entry point for 'xdcget' CLI invocation."""
|
||||
parser = get_parser()
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
|
||||
[params]
|
||||
|
||||
# mail domain (MUST be set to fully qualified chat mail domain)
|
||||
mailname = {mailname}
|
||||
|
||||
#
|
||||
# If you only do private test deploys, you don't need to modify any settings below
|
||||
#
|
||||
|
||||
# how many mails a user can send out per minute
|
||||
max_user_send_per_minute = 60
|
||||
|
||||
# list of e-mail recipients for which to accept outbound un-encrypted mails
|
||||
passthrough_recipients =
|
||||
|
||||
# where the filtermail SMTP service listens
|
||||
filtermail_smtp_port = 10080
|
||||
|
||||
# postfix accepts on the localhost reinject SMTP port
|
||||
postfix_reinject_port = 10025
|
||||
|
||||
# postal address of privacy contact
|
||||
privacy_postal =
|
||||
|
||||
# email address of privacy contact
|
||||
privacy_mail =
|
||||
|
||||
# postal address of the privacy data officer
|
||||
privacy_pdo =
|
||||
|
||||
# postal address of the privacy supervisor
|
||||
privacy_supervisor =
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
[privacy]
|
||||
|
||||
passthrough_recipients = privacy@testrun.org
|
||||
|
||||
privacy_postal =
|
||||
Merlinux GmbH, Represented by the managing director H. Krekel,
|
||||
Reichgrafen Str. 20, 79102 Freiburg, Germany
|
||||
|
||||
privacy_mail = privacy@testrun.org
|
||||
privacy_pdo =
|
||||
Prof. Dr. Fabian Schmieder, lexICT UG (limited), Ostfeldstr. 49, 30559 Hannover.
|
||||
You can contact him at *delta-privacy@merlinux.eu* (Keyword: DPO)
|
||||
privacy_supervisor =
|
||||
State Commissioner for Data Protection and Freedom of Information of
|
||||
Baden-Württemberg in 70173 Stuttgart, Germany.
|
||||
Reference in New Issue
Block a user