From 4947c4df8dc3e8a7cafb5d5b0f017f37d4d1ec10 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 15 May 2011 12:25:19 +0100 Subject: [PATCH] Add --hostname option. --- vmdebootstrap | 11 +++++++++++ vmdebootstrap.8 | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/vmdebootstrap b/vmdebootstrap index 5ee3277..19238c7 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -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') diff --git a/vmdebootstrap.8 b/vmdebootstrap.8 index fcb2ffb..834e4b2 100644 --- a/vmdebootstrap.8 +++ b/vmdebootstrap.8 @@ -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 -- 2.39.5