From 1378496cbe6c4bc5926d681470b297a7301a7885 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sat, 15 Nov 2025 13:05:17 +0100 Subject: [PATCH] Feat: first draft of yaml config --- debian/control | 2 +- .../linuxmusterLinuxclient7/config.py | 159 +++++++------- .../linuxmusterLinuxclient7/constants.py | 3 +- .../linuxmusterLinuxclient7/requirements.txt | 1 + .../linuxmusterLinuxclient7/setup.py | 9 +- .../files/config/config.invalid-network.yml | 4 + .../files/config/config.invalid-syntax.yml | 5 + .../tests/files/config/config.yml | 4 + .../tests/files/config/network.conf | 5 + .../tests/files/config/network.invalid.conf | 5 + .../tests/test_config.py | 201 ++++++++++++++++++ wiki/Insights/Domain-join.md | 2 +- wiki/Insights/Upgrade-and-removal.md | 2 +- 13 files changed, 313 insertions(+), 89 deletions(-) create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-network.yml create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-syntax.yml create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.yml create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.conf create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.invalid.conf create mode 100644 usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/test_config.py diff --git a/debian/control b/debian/control index 0122971..7154e0c 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,6 @@ Standards-Version: 5.0.0 Package: linuxmuster-linuxclient7 Architecture: all -Depends: python3, python3-ldap, cifs-utils, ldb-tools, bind9-host, ipcalc, hxtools, network-manager, krb5-user, keyutils, samba, sssd, sssd-tools, libsss-sudo, adcli, libpam-sss, sudo, realmd, cups (>= 2.3.0), coreutils, libcap2-bin +Depends: python3, python3-ldap, python3-yaml, cifs-utils, ldb-tools, bind9-host, ipcalc, hxtools, network-manager, krb5-user, keyutils, samba, sssd, sssd-tools, libsss-sudo, adcli, libpam-sss, sudo, realmd, cups (>= 2.3.0), coreutils, libcap2-bin Description: Package for Ubuntu clients to connect to the linuxmuster.net 7 active directory server. Conflicts: linuxmuster-client-adsso, linuxmuster-client-adsso7, ni-lmn-client-adsso diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/config.py b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/config.py index bbfbaf9..5c380e0 100644 --- a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/config.py +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/config.py @@ -1,5 +1,5 @@ -import configparser, re -from linuxmusterLinuxclient7 import logging, constants +import configparser, os, yaml +from linuxmusterLinuxclient7 import logging, constants, fileHelper def network(): """ @@ -8,59 +8,36 @@ def network(): :return: Tuple (success, dict of keys) :rtype: tuple """ - rc, rawNetworkConfig = _readNetworkConfig() - if not rc: + config = _readConfig() + if config is None or not "network" in config: return False, None - if not _checkNetworkConfigVersion(rawNetworkConfig)[0]: - return False, None - - networkConfig = {} - - try: - networkConfig["serverHostname"] = rawNetworkConfig["serverHostname"] - networkConfig["domain"] = rawNetworkConfig["domain"] - networkConfig["realm"] = rawNetworkConfig["realm"] - except KeyError as e: - logging.error("Error when reading network.conf (2)") - logging.exception(e) + networkConfig = config["network"] + if not _validateNetworkConfig(networkConfig): + logging.error("Error when reading network.conf") return False, None return True, networkConfig def writeNetworkConfig(newNetworkConfig): """ - Write the network configuration in `/etc/linuxmuster-linuxclient7/network.conf` + Write the network configuration in `/etc/linuxmuster-linuxclient7/config.yml`. + Preserves other configurations. :param newNetworkConfig: The new config :type newNetworkConfig: dict :return: True or False :rtype: bool """ - networkConfig = configparser.ConfigParser(interpolation=None) - - try: - networkConfig["network"] = {} - networkConfig["network"]["version"] = str(_networkConfigVersion()) - networkConfig["network"]["serverHostname"] = newNetworkConfig["serverHostname"] - networkConfig["network"]["domain"] = newNetworkConfig["domain"] - networkConfig["network"]["realm"] = newNetworkConfig["realm"] - except Exception as e: - logging.error("Error when preprocessing new network configuration!") - logging.exception(e) + if not _validateNetworkConfig(newNetworkConfig): return False - try: - logging.info("Writing new network Configuration") - with open(constants.networkConfigFilePath, 'w') as networkConfigFile: - networkConfig.write(networkConfigFile) + config = _readConfig() + if config is None: + config = {} + config["network"] = newNetworkConfig - except Exception as e: - logging.error("Failed!") - logging.exception(e) - return False - - return True + return _writeConfig(config) def upgrade(): """ @@ -70,67 +47,87 @@ def upgrade(): :return: True or False :rtype: bool """ - return _upgradeNetworkConfig() + return _upgrade() + +def delete(): + """ + Delete the network configuration file. + + :return: True or False + :rtype: bool + """ + legacyNetworkConfigFleDeleted = fileHelper.deleteFile(constants.legacyNetworkConfigFilePath) + configFileDeleted = fileHelper.deleteFile(constants.configFilePath) + return legacyNetworkConfigFleDeleted and configFileDeleted + # -------------------- # - Helper functions - # -------------------- -def _readNetworkConfig(): +def _readConfig(): + if not os.path.exists(constants.configFilePath): + networkConfig = _readLegacyNetworkConfig() + return {"network": networkConfig} if networkConfig is not None else None + + try: + with open(constants.configFilePath, "r") as configFile: + yamlContent = configFile.read() + config = yaml.safe_load(yamlContent) + return config + except Exception as e: + logging.error("Error when reading config.yml") + logging.exception(e) + return None + +def _readLegacyNetworkConfig(): configParser = configparser.ConfigParser() - configParser.read(constants.networkConfigFilePath) + configParser.read(constants.legacyNetworkConfigFilePath) try: rawNetworkConfig = configParser["network"] - return True, rawNetworkConfig + networkConfig = { + "serverHostname": rawNetworkConfig["serverHostname"], + "domain": rawNetworkConfig["domain"], + "realm": rawNetworkConfig["realm"] + } + return networkConfig except KeyError as e: logging.error("Error when reading network.conf (1)") logging.exception(e) - return False, None - return configParser - -def _networkConfigVersion(): - return 1 + return None -def _checkNetworkConfigVersion(rawNetworkConfig): +def _writeConfig(config): try: - networkConfigVersion = int(rawNetworkConfig["version"]) - except KeyError as e: - logging.warning("The network.conf version could not be identified, assuming 0") - networkConfigVersion = 0 - - if networkConfigVersion != _networkConfigVersion(): - logging.warning("The network.conf Version is a mismatch!") - return False, networkConfigVersion - - return True, networkConfigVersion - -def _upgradeNetworkConfig(): - logging.info("Upgrading network config.") - rc, rawNetworkConfig = _readNetworkConfig() - if not rc: + with open(constants.configFilePath, "w") as configFile: + yamlContent = yaml.dump(config) + configFile.write(yamlContent) + return True + except Exception as e: + logging.error("Error when writing config.yml") + logging.exception(e) return False - rc, networkConfigVersion = _checkNetworkConfigVersion(rawNetworkConfig) - if rc: +def _validateNetworkConfig(networkConfig): + requiredKeys = {"serverHostname", "domain", "realm"} + return networkConfig is not None and networkConfig.keys() >= requiredKeys + +def _upgrade(): + logging.info("Upgrading config.") + if os.path.exists(constants.configFilePath): logging.info("No need to upgrade, already up-to-date.") return True - logging.info("Upgrading network config from {0} to {1}".format(networkConfigVersion, _networkConfigVersion())) - - if networkConfigVersion > _networkConfigVersion(): - logging.error("Cannot upgrade from a newer version to an older one!") - return False + logging.info("Upgrading config from network.conf to config.yml") - try: - if networkConfigVersion == 0: - newNetworkConfig = {} - newNetworkConfig["serverHostname"] = rawNetworkConfig["serverHostname"] + "." + rawNetworkConfig["domain"] - newNetworkConfig["domain"] = rawNetworkConfig["domain"] - newNetworkConfig["realm"] = rawNetworkConfig["domain"].upper() - return writeNetworkConfig(newNetworkConfig) - except Exception as e: - logging.error("Error when upgrading network config!") - logging.exception(e) + config = _readConfig() + if config is None or not "network" in config or not _validateNetworkConfig(config["network"]): + logging.error("Error when upgrading config, network.conf is invalid") return False - + + if not _writeConfig(config): + logging.error("Error when upgrading config, could not write config.yml") + return False + + fileHelper.deleteFile(constants.legacyNetworkConfigFilePath) + logging.info("Config upgrade successfull") return True \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/constants.py b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/constants.py index 06cfdf5..1cd5422 100644 --- a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/constants.py +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/constants.py @@ -16,7 +16,8 @@ configFileTemplateDir = shareBaseDir + "/templates" scriptDir = shareBaseDir + "/scripts" -networkConfigFilePath = etcBaseDir + "/network.conf" +legacyNetworkConfigFilePath = etcBaseDir + "/network.conf" +configFilePath = etcBaseDir + "/config.yml" # {} will be substituted for the username tmpEnvironmentFilePath = "/home/{}/.linuxmuster-linuxclient7-environment.sh" diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/requirements.txt b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/requirements.txt index a274df9..c091f7f 100644 --- a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/requirements.txt +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/requirements.txt @@ -11,3 +11,4 @@ pytest==7.1.1 pytest-cov==3.0.0 python-ldap==3.4.0 tomli==2.0.1 +pyyaml==6.0 \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py index 0494071..c925200 100644 --- a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py @@ -179,7 +179,8 @@ def isSetup(): :return: True if setup, False otherwise :rtype: bool """ - return os.path.isfile(constants.networkConfigFilePath) + rc, networkConfig = config.network() + return rc and networkConfig is not None # -------------------- # - Helper functions - @@ -209,9 +210,9 @@ def _cleanOldDomainJoins(): if not fileHelper.deleteFilesWithExtension("/var/lib/samba/private/tls", ".pem"): return False - # remove network.conf - logging.info(f"Deleting {constants.networkConfigFilePath} if exists ...") - if not fileHelper.deleteFile(constants.networkConfigFilePath): + # remove configuration + logging.info(f"Deleting configuration files if exist ...") + if not config.delete(): return False return True diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-network.yml b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-network.yml new file mode 100644 index 0000000..4036734 --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-network.yml @@ -0,0 +1,4 @@ +network: + sserverHostname: server.linuxmuster.lan + ddomain: linuxmuster.lan + rrealm: LINUXMUSTER.LAN \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-syntax.yml b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-syntax.yml new file mode 100644 index 0000000..c2054f4 --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.invalid-syntax.yml @@ -0,0 +1,5 @@ +*-? +network: + serverHostname: server.linuxmuster.lan + domain: linuxmuster.lan + realm: LINUXMUSTER.LAN \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.yml b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.yml new file mode 100644 index 0000000..8585e52 --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/config.yml @@ -0,0 +1,4 @@ +network: + serverHostname: server.linuxmuster.lan + domain: linuxmuster.lan + realm: LINUXMUSTER.LAN \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.conf b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.conf new file mode 100644 index 0000000..1ec792f --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.conf @@ -0,0 +1,5 @@ +[network] +version = 1 +serverhostname = server.linuxmuster.legacy +domain = linuxmuster.legacy +realm = LINUXMUSTER.LEGACY \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.invalid.conf b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.invalid.conf new file mode 100644 index 0000000..78242d9 --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/files/config/network.invalid.conf @@ -0,0 +1,5 @@ +[network] +version = 1 +sserverhostname = server.linuxmuster.legacy +ddomain = linuxmuster.legacy +rrealm = LINUXMUSTER.LEGACY \ No newline at end of file diff --git a/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/test_config.py b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/test_config.py new file mode 100644 index 0000000..219553c --- /dev/null +++ b/usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests/test_config.py @@ -0,0 +1,201 @@ +import os, yaml +from unittest import mock +from .. import config + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml") +def test_network_legacy(): + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.legacy" + assert networkConfig["domain"] == "linuxmuster.legacy" + assert networkConfig["realm"] == "LINUXMUSTER.LEGACY" + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/config.yml") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml") +def test_network(): + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.lan" + assert networkConfig["domain"] == "linuxmuster.lan" + assert networkConfig["realm"] == "LINUXMUSTER.LAN" + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml") +def test_network_both(): + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.lan" + assert networkConfig["domain"] == "linuxmuster.lan" + assert networkConfig["realm"] == "LINUXMUSTER.LAN" + + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml") +def test_network_none(): + rc, networkConfig = config.network() + assert not rc + assert networkConfig is None + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.invalid-network.yml") +def test_network_invalid(): + rc, networkConfig = config.network() + assert not rc + assert networkConfig is None + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.invalid-syntax.yml") +def test_syntax_invalid(): + rc, networkConfig = config.network() + assert not rc + assert networkConfig is None + +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_writeNetworkConfig(): + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + with open(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml", "r") as fsrc: + with open("/tmp/config.yml", "w") as fdst: + fdst.write(fsrc.read()) + + newNetworkConfig = { + "serverHostname": "server.linuxmuster.new", + "domain": "linuxmuster.new", + "realm": "LINUXMUSTER.NEW" + } + assert config.writeNetworkConfig(newNetworkConfig) + + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.new" + assert networkConfig["domain"] == "linuxmuster.new" + assert networkConfig["realm"] == "LINUXMUSTER.NEW" + + # TODO: once there are more config options, test that they are preserved + +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_writeNetworkConfig_invalid(): + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + with open(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml", "r") as fsrc: + with open("/tmp/config.yml", "w") as fdst: + fdst.write(fsrc.read()) + + newNetworkConfig = { + "sserverHostname": "server.linuxmuster.new", + "domain": "linuxmuster.new", + "realm": "LINUXMUSTER.NEW" + } + assert not config.writeNetworkConfig(newNetworkConfig) + + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.lan" + assert networkConfig["domain"] == "linuxmuster.lan" + assert networkConfig["realm"] == "LINUXMUSTER.LAN" + +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml") +def test_writeNetworkConfig_invalidPath(): + + newNetworkConfig = { + "serverHostname": "server.linuxmuster.new", + "domain": "linuxmuster.new", + "realm": "LINUXMUSTER.NEW" + } + assert not config.writeNetworkConfig(newNetworkConfig) + +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_writeNetworkConfig_empty(): + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + newNetworkConfig = { + "serverHostname": "server.linuxmuster.new", + "domain": "linuxmuster.new", + "realm": "LINUXMUSTER.NEW" + } + assert config.writeNetworkConfig(newNetworkConfig) + + rc, networkConfig = config.network() + assert rc + assert networkConfig["serverHostname"] == "server.linuxmuster.new" + assert networkConfig["domain"] == "linuxmuster.new" + assert networkConfig["realm"] == "LINUXMUSTER.NEW" + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/tmp/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_upgrade(): + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + if os.path.exists("/tmp/network.conf"): + os.remove("/tmp/network.conf") + + with open(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.conf", "r") as fsrc: + with open("/tmp/network.conf", "w") as fdst: + fdst.write(fsrc.read()) + + assert config.upgrade() + assert not os.path.exists("/tmp/network.conf") + assert os.path.exists("/tmp/config.yml") + + with open("/tmp/config.yml", "r") as f: + content = f.read() + print(content) + yamlContent = yaml.safe_load(content) + assert "network" in yamlContent + assert yamlContent["network"]["serverHostname"] == "server.linuxmuster.legacy" + assert yamlContent["network"]["domain"] == "linuxmuster.legacy" + assert yamlContent["network"]["realm"] == "LINUXMUSTER.LEGACY" + + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml") +def test_upgrade_alreadyUpToDate(): + assert config.upgrade() + + with open(config.constants.configFilePath, "r") as f: + content = f.read() + print(content) + yamlContent = yaml.safe_load(content) + assert "network" in yamlContent + assert yamlContent["network"]["serverHostname"] == "server.linuxmuster.lan" + assert yamlContent["network"]["domain"] == "linuxmuster.lan" + assert yamlContent["network"]["realm"] == "LINUXMUSTER.LAN" + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.invalid.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_upgrade_invalid(): + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + assert not config.upgrade() + assert os.path.exists(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.invalid.conf") + assert not os.path.exists("/tmp/config.yml") + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml") +def test_upgrade_nonexistent(): + assert not config.upgrade() + +@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/tmp/network.conf") +@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/tmp/config.yml") +def test_delete(): + if os.path.exists("/tmp/network.conf"): + os.remove("/tmp/network.conf") + if os.path.exists("/tmp/config.yml"): + os.remove("/tmp/config.yml") + + with open(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/network.conf", "r") as fsrc: + with open("/tmp/network.conf", "w") as fdst: + fdst.write(fsrc.read()) + with open(f"{os.path.dirname(os.path.realpath(__file__))}/files/config/config.yml", "r") as fsrc: + with open("/tmp/config.yml", "w") as fdst: + fdst.write(fsrc.read()) + + assert config.delete() + assert not os.path.exists("/tmp/network.conf") + assert not os.path.exists("/tmp/config.yml") \ No newline at end of file diff --git a/wiki/Insights/Domain-join.md b/wiki/Insights/Domain-join.md index 5bcf4b7..5c7a2dd 100644 --- a/wiki/Insights/Domain-join.md +++ b/wiki/Insights/Domain-join.md @@ -6,7 +6,7 @@ The domain join works like this: - If a domain was specified using the `--domain` parameter, and this domain is found, it will be joined - If no domain was specified, the first discovered domain will be joined - If no domain was found or the specified domain was not found, the setup will exit with an error -- 4 The `/etc/linuxmuster-linuxclient7/network.conf` file is written +- 4 The `/etc/linuxmuster-linuxclient7/config.yml` file is written - The necessary details are queried using `adcli info $DOMAIN` where `$DOMAIN` is the domain which is going to be joined - 5 All templates in `/usr/share/linuxmuster-linuxclient7/templates` are applied - 6 Services are restarted diff --git a/wiki/Insights/Upgrade-and-removal.md b/wiki/Insights/Upgrade-and-removal.md index a900007..cb98b9c 100644 --- a/wiki/Insights/Upgrade-and-removal.md +++ b/wiki/Insights/Upgrade-and-removal.md @@ -2,7 +2,7 @@ On every upgrade, the command `linuxmuster-linuxclient7 upgrade` is executed. It does the following: 1. Check if linuxmuster-linuxclient7 is set up 2. Upgrade config files if required: - - `/etc/linuxmuster-linuxclient7/network.conf` + - `/etc/linuxmuster-linuxclient7/network.conf` -> `/etc/linuxmuster-linuxclient7/config.yml` 3. Apply all templates. 4. Restart services. 5. Delete old files which could cause conflicts