commit: 3c2d2560342a8bc8b6aecb00d7940fbc6dc03e12
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 13 12:43:14 2024 +0000
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Oct 13 12:43:14 2024 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3c2d2560
New attempt at systemd-firstboot
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
targets/support/create-qcow2.sh | 8 ++++++--
targets/support/diskimage-installation.sh | 20 ++++++--------------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/targets/support/create-qcow2.sh b/targets/support/create-qcow2.sh
index f7c1a08a..0073a25c 100755
--- a/targets/support/create-qcow2.sh
+++ b/targets/support/create-qcow2.sh
@@ -140,8 +140,12 @@ mount ${mypartefi} "${mymountpoint}/boot" || qcow2die
"Could not mount boot part
echo "Copying files into the mounted directories from ${clst_stage_path}"
cp -a "${clst_stage_path}"/* "${mymountpoint}/" || qcow2die "Could not copy
content into mounted image"
-echo "Setting machine-id to uninitialized"
-echo "uninitialized" > "${mymountpoint}/etc/machine-id" || qcow2die "Could not
set machine-id to uninitialized"
+echo "Setting machine-id to empty"
+# We are already running systemd-firstboot in a previous step, so we don't
want to run it again.
+# The documented behaviour for an empty machine-id is that systemd generates a
new one and commits
+# it on first boot, but otherwise treats the system as already initialized.
+rm -f "${mymountpoint}/etc/machine-id"
+touch "${mymountpoint}/etc/machine-id" || qcow2die "Could not set machine-id
to empty"
# now we can chroot in and install grub
exec_in_qcow2 "${clst_shdir}/support/qcow2-grub-install.sh"
diff --git a/targets/support/diskimage-installation.sh
b/targets/support/diskimage-installation.sh
index 5d9ff2e1..c7ee4f0b 100755
--- a/targets/support/diskimage-installation.sh
+++ b/targets/support/diskimage-installation.sh
@@ -19,31 +19,23 @@ if [[ $(readlink /etc/portage/make.profile) == *systemd* ]]
; then
echo "Generating /etc/locale.gen"
cat > /etc/locale.gen <<END
en_US ISO-8859-1
-en_US.utf8 UTF-8
+en_US.UTF-8 UTF-8
END
echo "Running systemctl preset-all"
systemctl preset-all || die "Running systemctl preset-all failed"
-# Provide configuration for systemd-firstboot
-# We need enough information so all questions are skipped
-mkdir -p /etc/systemd/system/systemd-firstboot.service.d || die "mkdir failed"
-mysfconfigfile=/etc/systemd/system/systemd-firstboot.service.d/00gentoo.conf
-
-mysfconfig_console=$(cat <<END
-[Service]
-ExecStart=systemd-firstboot --locale=en_US.utf8 --keymap=us --timezone=UTC
--root-password=gentoo
-END
-)
-
echo "Disk image type is ${clst_diskimage_type}"
case ${clst_diskimage_type} in
generic)
echo "Setting up generic image (warning, not very useful on its
own)"
+ echo "Running systemd-firstboot"
+ systemd-firstboot --locale=en_US.UTF-8 --keymap=us
--timezone=UTC || die "Failed running systemd-firstboot"
;;
console)
- echo "Setting up console image. Please change the root
password."
- echo "${mysfconfig_console}" > "${mysfconfigfile}"
+ echo "Setting up console log-in image. Please set the root
password ASAP."
+ echo "Running systemd-firstboot"
+ systemd-firstboot --locale=en_US.UTF-8 --keymap=us
--timezone=UTC --delete-root-password || die "Failed running systemd-firstboot"
;;
*)
die "As yet unsupported image type"