[zfshostid] adding new module

module created to copy zfs generated /etc/hostid, needed to have
hostid in zpool & initramfs in sync
This commit is contained in:
demmm 2022-10-16 13:35:09 +02:00
parent 1b96832bf7
commit 089d3086cc
4 changed files with 64 additions and 0 deletions

View File

@ -140,6 +140,7 @@ sequence:
# - luksopenswaphookcfg
# - dracutlukscfg
# - plymouthcfg
# - zfshostid
- initcpiocfg
- initcpio
- users

View File

@ -0,0 +1,45 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <https://calamares.io> ===
#
# SPDX-FileCopyrightText: 2022 Anke Boersma <demm@kaosx.us>
# 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

View File

@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
---
type: "job"
name: "zfshostid"
interface: "python"
script: "main.py"
noconfig: true

View File

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Anke Boersma <demm@kaosx.us>
# 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