generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Events.mail-settings-changed registered
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2022 Nethesis S.r.l.s | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import json | ||
import sys | ||
import agent | ||
import os | ||
|
||
event = json.load(sys.stdin) | ||
|
||
if event['module_uuid'] == os.getenv('MAIL_SERVER', ''): | ||
# Restart to apply changed settings | ||
rdb = agent.redis_connect() | ||
|
||
# retrieve mail module_hostname from module_uuid | ||
mail_server = os.environ["MAIL_SERVER"] | ||
providers = agent.list_service_providers(rdb, 'imap', 'tcp', { | ||
'module_uuid': mail_server, | ||
}) | ||
mail_hostname = providers[0]["mail_hostname"] | ||
agent.set_env("MAIL_HOSTNAME",mail_hostname) | ||
agent.run_helper("systemctl", "--user", "try-restart", "imapsync.service").check_returncode() |