]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Ignore failure to set host name
authorTollef Fog Heen <tfheen@fastly.com>
Mon, 7 Apr 2014 08:53:52 +0000 (10:53 +0200)
committerTollef Fog Heen <tfheen@err.no>
Mon, 7 Apr 2014 08:53:52 +0000 (10:53 +0200)
At least minbase does not end up with an /etc/hosts file, so ignore
IOErrors for the hosts file.

vmdebootstrap

index 3344a59b41308e2d2cbcbf3a36f0b2293cd01974..a9f9e9bf4c2b87e6886f7c170dfca3dc3ed93b1d 100755 (executable)
@@ -292,13 +292,16 @@ class VmDebootstrap(cliapp.Application):
             f.write('%s\n' % hostname)
             
         etc_hosts = os.path.join(rootdir, 'etc', 'hosts')
-        with open(etc_hosts, 'r') as f:
-            data = f.read()
-        with open(etc_hosts, 'w') as f:
-            for line in data.splitlines():
-                if line.startswith('127.0.0.1'):
-                    line += ' %s' % hostname
-                f.write('%s\n' % line)
+        try:
+            with open(etc_hosts, 'r') as f:
+                data = f.read()
+            with open(etc_hosts, 'w') as f:
+                for line in data.splitlines():
+                    if line.startswith('127.0.0.1'):
+                        line += ' %s' % hostname
+                    f.write('%s\n' % line)
+        except IOError, e:
+            pass
 
     def create_fstab(self, rootdir, rootdev, roottype, bootdev, boottype):
         def fsuuid(device):