]> git.siccegge.de Git - forks/vmdebootstrap.git/blobdiff - vmdebootstrap
Add a rudimentary /etc/fstab.
[forks/vmdebootstrap.git] / vmdebootstrap
index 2fc55902d425f368387f3187d6c866d17e31a287..b5e02a0f1d8d82eb004aa4543e0d515ea6376f23 100755 (executable)
@@ -77,6 +77,7 @@ class VmDebootstrap(cliapp.Application):
             rootdir = self.mount(rootdev)
             self.debootstrap(rootdir)
             self.set_hostname(rootdir)
+            self.create_fstab(rootdir)
             self.set_root_password(rootdir)
             self.remove_udev_persistent_rules(rootdir)
             self.setup_networking(rootdir)
@@ -174,6 +175,21 @@ class VmDebootstrap(cliapp.Application):
         hostname = self.settings['hostname']
         with open(os.path.join(rootdir, 'etc', 'hostname'), 'w') as f:
             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)
+
+    def create_fstab(self, rootdir):
+        fstab = os.path.join(rootdir, 'etc', 'fstab')
+        with open(fstab, 'w') as f:
+            f.write('proc /proc proc defaults 0 0\n')
+            f.write('/dev/sda1 / ext4 errors=remount-ro 0 1\n')
 
     def set_root_password(self, rootdir):
         if self.settings['root-password']: