mirror of
https://github.com/chatmail/relay.git
synced 2026-05-21 05:18:04 +00:00
cmdeploy: flag to disable postfix + dovecot for migration
This commit is contained in:
@@ -479,10 +479,11 @@ def deploy_mtail(config):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def deploy_chatmail(config_path: Path) -> None:
|
def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
|
||||||
"""Deploy a chat-mail instance.
|
"""Deploy a chat-mail instance.
|
||||||
|
|
||||||
:param config_path: path to chatmail.ini
|
:param config_path: path to chatmail.ini
|
||||||
|
:param disable_mail: whether to disable postfix & dovecot
|
||||||
"""
|
"""
|
||||||
config = read_config(config_path)
|
config = read_config(config_path)
|
||||||
check_config(config)
|
check_config(config)
|
||||||
@@ -624,19 +625,19 @@ def deploy_chatmail(config_path: Path) -> None:
|
|||||||
# because it creates authentication socket
|
# because it creates authentication socket
|
||||||
# required by Postfix.
|
# required by Postfix.
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="Start and enable Dovecot",
|
name="disable dovecot for now" if disable_mail else "Start and enable Dovecot",
|
||||||
service="dovecot.service",
|
service="dovecot.service",
|
||||||
running=True,
|
running=False if disable_mail else True,
|
||||||
enabled=True,
|
enabled=False if disable_mail else True,
|
||||||
restarted=dovecot_need_restart,
|
restarted=dovecot_need_restart if not disable_mail else False,
|
||||||
)
|
)
|
||||||
|
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="Start and enable Postfix",
|
name="disable postfix for now" if disable_mail else "Start and enable Postfix",
|
||||||
service="postfix.service",
|
service="postfix.service",
|
||||||
running=True,
|
running=False if disable_mail else True,
|
||||||
enabled=True,
|
enabled=False if disable_mail else True,
|
||||||
restarted=postfix_need_restart,
|
restarted=postfix_need_restart if not disable_mail else False,
|
||||||
)
|
)
|
||||||
|
|
||||||
systemd.service(
|
systemd.service(
|
||||||
|
|||||||
@@ -52,6 +52,12 @@ def run_cmd_options(parser):
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="don't actually modify the server",
|
help="don't actually modify the server",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--disable-mail",
|
||||||
|
dest="disable_mail",
|
||||||
|
action="store_true",
|
||||||
|
help="install/upgrade the server, but disable postfix & dovecot for now"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(args, out):
|
def run_cmd(args, out):
|
||||||
@@ -64,6 +70,7 @@ def run_cmd(args, out):
|
|||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["CHATMAIL_INI"] = args.inipath
|
env["CHATMAIL_INI"] = args.inipath
|
||||||
|
env["CHATMAIL_DISABLE_MAIL"] = "True" if args.disable_mail else ""
|
||||||
deploy_path = importlib.resources.files(__package__).joinpath("deploy.py").resolve()
|
deploy_path = importlib.resources.files(__package__).joinpath("deploy.py").resolve()
|
||||||
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
|
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
|
||||||
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path} -y"
|
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path} -y"
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ def main():
|
|||||||
"CHATMAIL_INI",
|
"CHATMAIL_INI",
|
||||||
importlib.resources.files("cmdeploy").joinpath("../../../chatmail.ini"),
|
importlib.resources.files("cmdeploy").joinpath("../../../chatmail.ini"),
|
||||||
)
|
)
|
||||||
|
disable_mail = bool(os.environ.get('CHATMAIL_DISABLE_MAIL'))
|
||||||
|
|
||||||
deploy_chatmail(config_path)
|
deploy_chatmail(config_path, disable_mail)
|
||||||
|
|
||||||
|
|
||||||
if pyinfra.is_cli:
|
if pyinfra.is_cli:
|
||||||
|
|||||||
Reference in New Issue
Block a user