From 0b0868822d0560510900f8d54d45f2497778510a Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Thu, 27 Nov 2014 21:08:50 +0100 Subject: [PATCH 1/3] Add a machineid module. The module creates /etc/machine-id and/or /var/lib/dbus/machine-id. By default, it is enabled and creates both files, making the latter a symlink to the former. --- settings.conf | 1 + src/modules/machineid/machineid.conf | 8 ++++++ src/modules/machineid/main.py | 42 ++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/modules/machineid/machineid.conf create mode 100644 src/modules/machineid/main.py diff --git a/settings.conf b/settings.conf index 2465b9fb7..9354e6cc2 100644 --- a/settings.conf +++ b/settings.conf @@ -34,6 +34,7 @@ install: - partition - mount - unpackfs +- machineid - fstab - locale - keyboard diff --git a/src/modules/machineid/machineid.conf b/src/modules/machineid/machineid.conf new file mode 100644 index 000000000..263687263 --- /dev/null +++ b/src/modules/machineid/machineid.conf @@ -0,0 +1,8 @@ +--- +# Whether to create /etc/machine-id for systemd. +systemd: true +# Whether to create /var/lib/dbus/machine-id for D-Bus. +dbus: true +# Whether /var/lib/dbus/machine-id should be a symlink to /etc/machine-id +# (ignored if dbus is false, or if there is no /etc/machine-id to point to). +symlink: true diff --git a/src/modules/machineid/main.py b/src/modules/machineid/main.py new file mode 100644 index 000000000..0f3801041 --- /dev/null +++ b/src/modules/machineid/main.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +# === This file is part of Calamares - === +# +# Copyright 2014, Kevin Kofler +# +# Calamares is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Calamares is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Calamares. If not, see . + +import libcalamares +import os + + +def run(): + root_mount_point = libcalamares.globalstorage.value("rootMountPoint") + enable_systemd = libcalamares.job.configuration["systemd"] + enable_dbus = libcalamares.job.configuration["dbus"] + enable_symlink = libcalamares.job.configuration["symlink"] + target_systemd_machineid_file = "{}/etc/machine-id".format(root_mount_point) + if enable_systemd: + if os.path.exists(target_systemd_machineid_file): + os.remove(target_systemd_machineid_file) + check_chroot_call("systemd-machine-id-setup") + if enable_dbus: + target_dbus_machineid_file = "{}/var/lib/dbus/machine-id".format(root_mount_point) + if os.path.exists(target_dbus_machineid_file): + os.remove(target_dbus_machineid_file) + if enable_symlink and os.path.exists(target_systemd_machineid_file): + check_chroot_call(["ln", "-s", "/etc/machine-id", "/var/lib/dbus/machine-id"]) + else: + check_chroot_call(["dbus-uuidgen", "--ensure"]) + return None From 5f99d51f807927b6c04b9e120804039f93d8a5c4 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Thu, 27 Nov 2014 21:11:56 +0100 Subject: [PATCH 2/3] machineid: Add missing import. --- src/modules/machineid/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/machineid/main.py b/src/modules/machineid/main.py index 0f3801041..bb3bb48d5 100644 --- a/src/modules/machineid/main.py +++ b/src/modules/machineid/main.py @@ -19,6 +19,7 @@ import libcalamares import os +from libcalamares.utils import check_chroot_call def run(): From 587e76aa56a736108fd94d233c344a4e25fff0b5 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Thu, 27 Nov 2014 22:18:34 +0100 Subject: [PATCH 3/3] machineid: Add modules.desc. --- src/modules/machineid/module.desc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/modules/machineid/module.desc diff --git a/src/modules/machineid/module.desc b/src/modules/machineid/module.desc new file mode 100644 index 000000000..8d42b64f5 --- /dev/null +++ b/src/modules/machineid/module.desc @@ -0,0 +1,5 @@ +--- +type: "job" +name: "machineid" +interface: "python" +script: "main.py"