forked from Mirror/pmbootstrap
pmbootstrap init: Ask for hostname, default: device name (#1327)
* Save "" (empty string) in the user's config as hostname if the user let it default to the name of the device. That way, when the device gets changed, the user won't get the old device's name as hostname by accident. * Add a test case
This commit is contained in:
parent
16af241e5e
commit
147082ec58
5 changed files with 95 additions and 3 deletions
|
@ -240,6 +240,18 @@ def ask_for_build_options(args, cfg):
|
|||
cfg["pmbootstrap"]["ccache_size"] = answer
|
||||
|
||||
|
||||
def ask_for_hostname(args, device):
|
||||
while True:
|
||||
ret = pmb.helpers.cli.ask(args, "Device hostname (short form, e.g. 'foo')",
|
||||
None, (args.hostname or device), True)
|
||||
if not pmb.helpers.other.validate_hostname(ret):
|
||||
continue
|
||||
# Don't store device name in user's config (gets replaced in install)
|
||||
if ret == device:
|
||||
return ""
|
||||
return ret
|
||||
|
||||
|
||||
def frontend(args):
|
||||
cfg = pmb.config.load(args)
|
||||
|
||||
|
@ -281,6 +293,9 @@ def frontend(args):
|
|||
# Configure timezone info
|
||||
cfg["pmbootstrap"]["timezone"] = ask_for_timezone(args)
|
||||
|
||||
# Hostname
|
||||
cfg["pmbootstrap"]["hostname"] = ask_for_hostname(args, device)
|
||||
|
||||
# Save config
|
||||
pmb.config.save(args, cfg)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue