[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:
parent
1b96832bf7
commit
089d3086cc
@ -140,6 +140,7 @@ sequence:
|
|||||||
# - luksopenswaphookcfg
|
# - luksopenswaphookcfg
|
||||||
# - dracutlukscfg
|
# - dracutlukscfg
|
||||||
# - plymouthcfg
|
# - plymouthcfg
|
||||||
|
# - zfshostid
|
||||||
- initcpiocfg
|
- initcpiocfg
|
||||||
- initcpio
|
- initcpio
|
||||||
- users
|
- users
|
||||||
|
45
src/modules/zfshostid/main.py
Normal file
45
src/modules/zfshostid/main.py
Normal 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
|
8
src/modules/zfshostid/module.desc
Normal file
8
src/modules/zfshostid/module.desc
Normal 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
|
10
src/modules/zfshostid/zfshostid.schema.yaml
Normal file
10
src/modules/zfshostid/zfshostid.schema.yaml
Normal 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
|
Loading…
Reference in New Issue
Block a user