Skip to content

Commit

Permalink
Events.mail-settings-changed registered
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Sep 28, 2023
1 parent 293763b commit 6c37dcf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions imageroot/events/mail-settings-changed/80start_services
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()

0 comments on commit 6c37dcf

Please sign in to comment.