diff --git a/settings.conf b/settings.conf index 8f4d60213..f4cbd05ca 100644 --- a/settings.conf +++ b/settings.conf @@ -140,6 +140,7 @@ sequence: # - luksopenswaphookcfg # - dracutlukscfg # - plymouthcfg +# - zfshostid - initcpiocfg - initcpio - users diff --git a/src/modules/zfshostid/main.py b/src/modules/zfshostid/main.py new file mode 100644 index 000000000..4e7960e93 --- /dev/null +++ b/src/modules/zfshostid/main.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# === This file is part of Calamares - === +# +# SPDX-FileCopyrightText: 2022 Anke Boersma +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Calamares is Free Software: see the License-Identifier above. +# + +import os +import shutil + +import libcalamares +from libcalamares.utils import gettext_path, gettext_languages + + +import gettext +_ = gettext.translation("calamares-python", + localedir=libcalamares.utils.gettext_path(), + languages=libcalamares.utils.gettext_languages(), + fallback=True).gettext + + +def pretty_name(): + return _("Copying zfs generated hostid.") + + +def run(): + + zfs = libcalamares.globalstorage.value("zfsDatasets") + root_mount_point = libcalamares.globalstorage.value("rootMountPoint") + + if zfs: + hostid_source = '/etc/hostid' + hostid_destination = '{!s}/etc/hostid'.format(root_mount_point) + + if os.path.exists(hostid_source): + try: + shutil.copy2(hostid_source, hostid_destination) + except Exception as e: + libcalamares.utils.warning("Could not copy hostid") + + return None diff --git a/src/modules/zfshostid/module.desc b/src/modules/zfshostid/module.desc new file mode 100644 index 000000000..13fec35be --- /dev/null +++ b/src/modules/zfshostid/module.desc @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +--- +type: "job" +name: "zfshostid" +interface: "python" +script: "main.py" +noconfig: true diff --git a/src/modules/zfshostid/zfshostid.schema.yaml b/src/modules/zfshostid/zfshostid.schema.yaml new file mode 100644 index 000000000..6a7a7b753 --- /dev/null +++ b/src/modules/zfshostid/zfshostid.schema.yaml @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2022 Anke Boersma +# SPDX-License-Identifier: GPL-3.0-or-later +--- +$schema: https://json-schema.org/schema# +$id: https://calamares.io/schemas/zfshostid +additionalProperties: false +type: object + +required: + - zfs