]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Add --hostname option.
authorLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 11:25:19 +0000 (12:25 +0100)
committerLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 11:25:19 +0000 (12:25 +0100)
vmdebootstrap
vmdebootstrap.8

index 5ee3277c96f4fcfc91605d947f4068d0a14f0de4..19238c7dab98deacb8d4aaa2bff42d3d9314d32f 100755 (executable)
@@ -63,6 +63,10 @@ class VmDebootstrap(cliapp.Application):
         self.settings.add_string_setting(['customize'],
                                          'run SCRIPT after setting up system',
                                          metavar='SCRIPT')
+        self.settings.add_string_setting(['hostname'],
+                                         'set name to HOSTNAME (%default)',
+                                         metavar='HOSTNAME',
+                                         default='debian')
 
     def process_args(self, args):
         if not self.settings['image']:
@@ -81,6 +85,7 @@ class VmDebootstrap(cliapp.Application):
             self.mkfs(rootdev)
             rootdir = self.mount(rootdev)
             self.debootstrap(rootdir)
+            self.set_hostname(rootdir)
             self.set_root_password(rootdir)
             self.remove_udev_persistent_rules(rootdir)
             self.setup_networking(rootdir)
@@ -173,6 +178,12 @@ class VmDebootstrap(cliapp.Application):
                      rootdir, 
                      self.settings['mirror']])
 
+    def set_hostname(self, rootdir):
+        hostname = self.settings['hostname']
+        f = open(os.path.join(rootdir, 'etc', 'hostname'), 'w')
+        f.write(hostname)
+        f.close()
+
     def set_root_password(self, rootdir):
         if self.settings['root-password']:
             self.message('Setting root password')
index fcb2ffbf9254f3c8be8107bad9f0a1b0ca780464..834e4b29d8486af399f566814ec0e8639a70b029 100644 (file)
@@ -135,6 +135,12 @@ Run
 after setting up the new system image.
 The script will get a single parameters:
 the path to the root directory of the newly installed system.
+.TP
+.BR \-\-hostname =\fINAME
+Set system hostname to
+.IR NAME .
+The default is 
+.IR debian .
 .SH EXAMPLE
 To create an image for the stable release of Debian:
 .nf