From 3524d4a0d0efe8d18b70e9e8d298d29a35a26091 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 11 Apr 2022 11:47:47 +0200 Subject: [PATCH] [users] Add "transient" for hostname-location --- src/modules/users/Config.cpp | 4 +++- src/modules/users/Config.h | 1 + src/modules/users/SetHostNameJob.cpp | 3 +++ src/modules/users/users.conf | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 1630ce9e3..36a0ca1bb 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -84,7 +84,9 @@ hostNameActionNames() static const NamedEnumTable< HostNameAction > names { { QStringLiteral( "none" ), HostNameAction::None }, { QStringLiteral( "etcfile" ), HostNameAction::EtcHostname }, - { QStringLiteral( "hostnamed" ), HostNameAction::SystemdHostname } + { QStringLiteral( "etc" ), HostNameAction::EtcHostname }, + { QStringLiteral( "hostnamed" ), HostNameAction::SystemdHostname }, + { QStringLiteral( "transient" ), HostNameAction::Transient }, }; // clang-format on // *INDENT-ON* diff --git a/src/modules/users/Config.h b/src/modules/users/Config.h index 14e29d1e6..75c2d4bda 100644 --- a/src/modules/users/Config.h +++ b/src/modules/users/Config.h @@ -25,6 +25,7 @@ enum class HostNameAction None, EtcHostname, // Write to /etc/hostname directly SystemdHostname, // Set via hostnamed(1) + Transient, // Force target system transient, remove /etc/hostname }; const NamedEnumTable< HostNameAction >& hostNameActionNames(); diff --git a/src/modules/users/SetHostNameJob.cpp b/src/modules/users/SetHostNameJob.cpp index 6d35245cd..94b71f568 100644 --- a/src/modules/users/SetHostNameJob.cpp +++ b/src/modules/users/SetHostNameJob.cpp @@ -146,6 +146,9 @@ SetHostNameJob::exec() // Does its own logging setSystemdHostname( m_config->hostName() ); break; + case HostNameAction::Transient: + CalamaresUtils::System::instance()->removeTargetFile( QStringLiteral( "/etc/hostname" ) ); + break; } if ( m_config->writeEtcHosts() ) diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index 22e7e0a68..c5cc8d2af 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -161,7 +161,9 @@ userShell: /bin/bash # - *location* How the hostname is set in the target system: # - *None*, to not set the hostname at all # - *EtcFile*, to write to `/etc/hostname` directly +# - *Etc*, identical to above # - *Hostnamed*, to use systemd hostnamed(1) over DBus +# - *Transient*, to remove `/etc/hostname` from the target # The default is *EtcFile*. Setting this to *None* will # hide the hostname field. # - *writeHostsFile* Should /etc/hosts be written with a hostname for