mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-12 17:07:23 +01:00
Change the remote_nextcloud web_update hook handler strategy
This commit is contained in:
@@ -72,17 +72,20 @@ def exec_hooks(hook_name, data):
|
||||
cur_handlers = handlers
|
||||
cur_mods_env = mods_env
|
||||
mutex.release()
|
||||
|
||||
handled_count = 0
|
||||
|
||||
for handler in cur_handlers:
|
||||
if handler['type'] == 'py':
|
||||
# load the python code and run the `do_hook` function
|
||||
log.debug('calling %s hook handler: %s' % (hook_name, handler['path']))
|
||||
module = importlib.import_module(handler['path'])
|
||||
do_hook = getattr(module, "do_hook")
|
||||
do_hook(hook_name, data, cur_mods_env)
|
||||
r = do_hook(hook_name, data, cur_mods_env)
|
||||
log.debug('hook handler %s(%s) returned: %s', handler['path'], hook_name, r)
|
||||
if r: handled_count = handled_count + 1
|
||||
|
||||
else:
|
||||
log.error('Unknown hook handler type in %s: %s', handler['path'], handler['type'])
|
||||
|
||||
return len(cur_handlers)
|
||||
return handled_count > 0
|
||||
|
||||
|
||||
@@ -116,9 +116,12 @@ def do_web_update(env):
|
||||
nginx_conf += make_domain_config(domain, [template0, template3], ssl_certificates, env)
|
||||
|
||||
# execute hooks
|
||||
hook_data = {'nginx_conf': nginx_conf}
|
||||
hooks.exec_hooks('web_update', hook_data)
|
||||
nginx_conf = hook_data['nginx_conf']
|
||||
hook_data = {
|
||||
'op':'pre-save',
|
||||
'nginx_conf':nginx_conf
|
||||
}
|
||||
if hooks.exec_hooks('web_update', hook_data):
|
||||
nginx_conf = hook_data['nginx_conf']
|
||||
|
||||
# Did the file change? If not, don't bother writing & restarting nginx.
|
||||
nginx_conf_fn = "/etc/nginx/conf.d/local.conf"
|
||||
|
||||
Reference in New Issue
Block a user