self.settings.add_string_setting(['root-password'],
'set root password',
metavar='PASSWORD')
+ 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']:
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)
self.install_extlinux(rootdev, rootdir)
+ self.customize(rootdir)
except:
self.cleanup()
raise
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')
for dirname in self.remove_dirs:
shutil.rmtree(dirname)
+ def customize(self, rootdir):
+ script = self.settings['customize']
+ if script:
+ self.message('Running customize script %s' % script)
+ self.runcmd([script, rootdir])
+
if __name__ == '__main__':
VmDebootstrap().run()