[users] Add .conf entries for hostname settings

- Set hostname not-at-all, or via one of two mechanisms
 - Write /etc/hosts or not
This commit is contained in:
Adriaan de Groot 2020-02-17 16:40:09 +01:00
parent 61d096c9ec
commit e74831fcb4
2 changed files with 42 additions and 12 deletions

View File

@ -141,8 +141,7 @@ UsersViewStep::onLeave()
j = new SetPasswordJob( "root", m_widget->getRootPassword() );
m_jobs.append( Calamares::job_ptr( j ) );
j = new SetHostNameJob( m_widget->getHostname(),
SetHostNameJob::Action::EtcHostname | SetHostNameJob::Action::EtcHosts );
j = new SetHostNameJob( m_widget->getHostname(), m_actions );
m_jobs.append( Calamares::job_ptr( j ) );
}
@ -206,4 +205,21 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// Now it might be explicitly set to empty, which is ok
Calamares::JobQueue::instance()->globalStorage()->insert( "userShell", shell );
using Action = SetHostNameJob::Action;
QString hostnameActionString = CalamaresUtils::getString( configurationMap, "setHostname" );
if ( hostnameActionString.isEmpty() )
{
hostnameActionString = QStringLiteral( "EtcFile" );
}
bool ok = false;
auto hostnameAction = hostnameActions().find( hostnameActionString, ok );
if ( !ok )
{
hostnameAction = Action::EtcHostname;
}
Action hostsfileAction = getBool( configurationMap, "writeHostsFile", true ) ? Action::EtcHosts : Action::None;
m_actions = hostsfileAction | hostnameAction;
}

View File

@ -28,13 +28,13 @@ defaultGroups:
# Disable when your Distribution does not require such a group.
autologinGroup: autologin
# You can control the initial state for the 'autologin checkbox' here.
# Possible values are:
# - true to check or
# Possible values are:
# - true to check or
# - false to uncheck
# These set the **initial** state of the checkbox.
doAutologin: true
# When *sudoersGroup* is set to a non-empty string, Calamares creates a
# When *sudoersGroup* is set to a non-empty string, Calamares creates a
# sudoers file for the user. This file is located at:
# `/etc/sudoers.d/10-installer`
# Remember to add the (value of) *sudoersGroup* to *defaultGroups*.
@ -48,8 +48,8 @@ sudoersGroup: wheel
# Setting this to false , causes the root account to be disabled.
setRootPassword: true
# You can control the initial state for the 'reuse password for root'
# checkbox here. Possible values are:
# - true to check or
# checkbox here. Possible values are:
# - true to check or
# - false to uncheck
#
# When checked, the user password is used for the root account too.
@ -96,18 +96,18 @@ passwordRequirements:
libpwquality:
- minlen=0
- minclass=0
# You can control the visibility of the 'strong passwords' checkbox here.
# Possible values are:
# - true to show or
# Possible values are:
# - true to show or
# - false to hide (default)
# the checkbox. This checkbox allows the user to choose to disable
# password-strength-checks. By default the box is **hidden**, so
# that you have to pick a password that satisfies the checks.
allowWeakPasswords: false
# You can control the initial state for the 'strong passwords' checkbox here.
# Possible values are:
# - true to uncheck or
# Possible values are:
# - true to uncheck or
# - false to check (default)
# the checkbox by default. Since the box is labeled to enforce strong
# passwords, in order to **allow** weak ones by default, the box needs
@ -122,3 +122,17 @@ allowWeakPasswordsDefault: false
# - set, non-empty, use that path as shell. No validation is done
# that the shell actually exists or is executable.
# userShell: /bin/bash
# Hostname setting
#
# The user can enter a hostname; this is configured into the system
# in some way; pick one of:
# - *None*, to not set the hostname at all
# - *EtcFile*, to write to `/etc/hostname` directly
# - *Hostnamed*, to use systemd hostnamed(1) over DBus
# The default is *EtcFile*.
setHostname: EtcFile
# Should /etc/hosts be written with a hostname for this machine
# (also adds localhost and some ipv6 standard entries).
writeHostsFile: true