[users] Add "transient" for hostname-location

This commit is contained in:
Adriaan de Groot 2022-04-11 11:47:47 +02:00
parent 3b0aa69ad3
commit 3524d4a0d0
4 changed files with 9 additions and 1 deletions

View File

@ -84,7 +84,9 @@ hostNameActionNames()
static const NamedEnumTable< HostNameAction > names { static const NamedEnumTable< HostNameAction > names {
{ QStringLiteral( "none" ), HostNameAction::None }, { QStringLiteral( "none" ), HostNameAction::None },
{ QStringLiteral( "etcfile" ), HostNameAction::EtcHostname }, { QStringLiteral( "etcfile" ), HostNameAction::EtcHostname },
{ QStringLiteral( "hostnamed" ), HostNameAction::SystemdHostname } { QStringLiteral( "etc" ), HostNameAction::EtcHostname },
{ QStringLiteral( "hostnamed" ), HostNameAction::SystemdHostname },
{ QStringLiteral( "transient" ), HostNameAction::Transient },
}; };
// clang-format on // clang-format on
// *INDENT-ON* // *INDENT-ON*

View File

@ -25,6 +25,7 @@ enum class HostNameAction
None, None,
EtcHostname, // Write to /etc/hostname directly EtcHostname, // Write to /etc/hostname directly
SystemdHostname, // Set via hostnamed(1) SystemdHostname, // Set via hostnamed(1)
Transient, // Force target system transient, remove /etc/hostname
}; };
const NamedEnumTable< HostNameAction >& hostNameActionNames(); const NamedEnumTable< HostNameAction >& hostNameActionNames();

View File

@ -146,6 +146,9 @@ SetHostNameJob::exec()
// Does its own logging // Does its own logging
setSystemdHostname( m_config->hostName() ); setSystemdHostname( m_config->hostName() );
break; break;
case HostNameAction::Transient:
CalamaresUtils::System::instance()->removeTargetFile( QStringLiteral( "/etc/hostname" ) );
break;
} }
if ( m_config->writeEtcHosts() ) if ( m_config->writeEtcHosts() )

View File

@ -161,7 +161,9 @@ userShell: /bin/bash
# - *location* How the hostname is set in the target system: # - *location* How the hostname is set in the target system:
# - *None*, to not set the hostname at all # - *None*, to not set the hostname at all
# - *EtcFile*, to write to `/etc/hostname` directly # - *EtcFile*, to write to `/etc/hostname` directly
# - *Etc*, identical to above
# - *Hostnamed*, to use systemd hostnamed(1) over DBus # - *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 # The default is *EtcFile*. Setting this to *None* will
# hide the hostname field. # hide the hostname field.
# - *writeHostsFile* Should /etc/hosts be written with a hostname for # - *writeHostsFile* Should /etc/hosts be written with a hostname for