summaryrefslogtreecommitdiff
path: root/install
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-04-13 00:18:22 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-04-13 00:18:22 +0000
commitcd60daa6f1ee2c6b13343d41c22916110eedae9c (patch)
treed943f551263f059d887d6203dbf35049dc720a4f /install
parent1cf95676b7939d5ee99511a85b00748e281336cd (diff)
downloadlive-cd60daa6f1ee2c6b13343d41c22916110eedae9c.tar.gz
Configure nodename
Diffstat (limited to 'install')
-rwxr-xr-xinstall30
1 files changed, 30 insertions, 0 deletions
diff --git a/install b/install
index b69b1b8..9271702 100755
--- a/install
+++ b/install
@@ -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()