diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-04-13 00:18:22 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-04-13 00:18:22 +0000 |
commit | cd60daa6f1ee2c6b13343d41c22916110eedae9c (patch) | |
tree | d943f551263f059d887d6203dbf35049dc720a4f /install | |
parent | 1cf95676b7939d5ee99511a85b00748e281336cd (diff) | |
download | live-cd60daa6f1ee2c6b13343d41c22916110eedae9c.tar.gz |
Configure nodename
Diffstat (limited to 'install')
-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() |