diff options
-rwxr-xr-x | install | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -684,6 +684,35 @@ swap - /tmp tmpfs - y except: pass +# http://stackoverflow.com/questions/2532053/validate-a-hostname-string +def isValidNodename(hostname): + if len(hostname) > 63: + return False + allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE) + return all(allowed.match(x) for x in hostname) + +def configure_nodename(): + nodename = 'sphere' + while True: + choice, entry = EntryWindow(screen, title='Set hostname', + text='Please enter the hostname for this system', + prompts=[('Hostname', nodename)], + width=70, entryWidth=63, buttons = ['Ok']) + nodename = entry[0].strip() + if isValidNodename(nodename): + break + ButtonChoiceWindow(screen, title='Invalid hostname', + text='The name "{}" is not a valid hostname'.format(nodename), + buttons=['Ok']) + try: + f = open(rootdir + '/etc/nodename', 'w') + print(nodename, file=f) + f.close() + except: + pass + +def configure_network(): + configure_nodename() def configure_bootenv(): progress = ProgressMessage(screen, title='Configuring Dyson boot environment', width=50) @@ -735,6 +764,7 @@ try: configure_zfs() install() configure_bootenv() + configure_network() cleanup() goodbye() |