system_setup: setup user with wsl.conf
This commit is contained in:
parent
7ae8e108a6
commit
271b72b41a
|
@ -111,12 +111,13 @@ def default_loader(is_advanced=False):
|
|||
return data
|
||||
|
||||
|
||||
def wsl_config_update(config_class, root_dir):
|
||||
def wsl_config_update(config_class, root_dir, default_user=None):
|
||||
"""
|
||||
This update the configuration file for the given class.zzd
|
||||
This update the configuration file for the given class.
|
||||
|
||||
:param config_class: WSLConfigurationBase or WSLConfigurationAdvanced
|
||||
:param is_dry_run: boolean, True if it is a dry run
|
||||
:param root_dir: string, the root directory of the WSL
|
||||
:param create_user: string, the user to create
|
||||
"""
|
||||
temp_conf_default = {}
|
||||
temp_confname = config_class.__str__()
|
||||
|
@ -162,6 +163,11 @@ def wsl_config_update(config_class, root_dir):
|
|||
config.add_section(config_section)
|
||||
config[config_section][config_setting] = config_value
|
||||
|
||||
if config_type == "wsl" and default_user is not None:
|
||||
if "user" not in config:
|
||||
config.add_section("user")
|
||||
config["user"]["default"] = default_user
|
||||
|
||||
# sort config in ascii order
|
||||
for section in config._sections:
|
||||
config._sections[section] = \
|
||||
|
|
|
@ -69,8 +69,10 @@ class ConfigureController(SubiquityController):
|
|||
dryrun = self.app.opts.dry_run
|
||||
variant = self.app.variant
|
||||
root_dir = self.model.root
|
||||
username = None
|
||||
if variant == "wsl_setup":
|
||||
wsl_id = self.model.identity.user
|
||||
username = wsl_id.username
|
||||
if dryrun:
|
||||
log.debug("mimicking creating user %s",
|
||||
wsl_id.username)
|
||||
|
@ -105,7 +107,8 @@ class ConfigureController(SubiquityController):
|
|||
wsl_config_update(self.model.wslconfadvanced.wslconfadvanced,
|
||||
root_dir)
|
||||
|
||||
wsl_config_update(self.model.wslconfbase.wslconfbase, root_dir)
|
||||
wsl_config_update(self.model.wslconfbase.wslconfbase, root_dir,
|
||||
default_user=username)
|
||||
|
||||
self.app.update_state(ApplicationState.DONE)
|
||||
except Exception:
|
||||
|
|
|
@ -6,3 +6,6 @@ root = /custom_mnt_path
|
|||
generatehosts = false
|
||||
generateresolvconf = false
|
||||
|
||||
[user]
|
||||
default = ubuntu
|
||||
|
||||
|
|
|
@ -12,3 +12,6 @@ enabled = false
|
|||
generatehosts = false
|
||||
generateresolvconf = false
|
||||
|
||||
[user]
|
||||
default = ubuntu
|
||||
|
||||
|
|
|
@ -6,3 +6,6 @@ root = /custom_mnt_path
|
|||
generatehosts = false
|
||||
generateresolvconf = false
|
||||
|
||||
[user]
|
||||
default = ubuntu
|
||||
|
||||
|
|
Loading…
Reference in New Issue