diff --git a/imageroot/actions/configure-module/90bind_user_domain b/imageroot/actions/configure-module/90bind_user_domain new file mode 100755 index 00000000..6201b8d9 --- /dev/null +++ b/imageroot/actions/configure-module/90bind_user_domain @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +# +# Copyright (C) 2024 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +# This script is linked to +# - configure-module +# - update-module.d/ + +import agent +import sys +import os +import json + +rdb = agent.redis_connect() +module_id = os.environ["MODULE_ID"] +has_file_server_flag = bool(rdb.sismember(f'module/{module_id}/flags', 'file_server')) +if has_file_server_flag: + domain = os.environ['REALM'].lower() + agent.bind_user_domains([domain], check=False) +else: + agent.bind_user_domains([], check=False) diff --git a/imageroot/bin/write-user-portal-config b/imageroot/bin/write-user-portal-config index 35f66762..cbe0581b 100755 --- a/imageroot/bin/write-user-portal-config +++ b/imageroot/bin/write-user-portal-config @@ -15,6 +15,7 @@ import json agent_install_dir = os.environ['AGENT_INSTALL_DIR'] # realm is mandatory we do not need to test it realm = os.environ["REALM"].lower() +module_id = os.environ["MODULE_ID"] with agent.redis_connect(use_replica=True) as rdb: modules_set = set() @@ -36,6 +37,13 @@ try: except Exception as ex: print(agent.SD_WARNING + "Failed to run cluster/list-modules action:", ex, file=sys.stderr) +# A Domain Controller acting as File Server provides additional services +# by itself. Let's tell the user about it: +has_file_server_flag = bool(rdb.sismember(f'module/{module_id}/flags', 'file_server')) +if has_file_server_flag: + names_set.add("Windows authentication") + names_set.add("Network shared folders") + # Write modules set to a JSON file data = {"domain": realm, "services": list(names_set)} diff --git a/imageroot/update-module.d/90bind_user_domain b/imageroot/update-module.d/90bind_user_domain new file mode 120000 index 00000000..fa926278 --- /dev/null +++ b/imageroot/update-module.d/90bind_user_domain @@ -0,0 +1 @@ +../actions/configure-module/90bind_user_domain \ No newline at end of file