X-Git-Url: https://git.siccegge.de//index.cgi?a=blobdiff_plain;ds=sidebyside;f=vmdebootstrap;h=5b4fa96187affa0fef7d292718eadd2d097554a5;hb=3520e4d1f4ef05386e4a3b12e66cd7b0dc7e327d;hp=ea5edff6784ddacc49ba8a54e171f67c5b49450e;hpb=7dba6126d384b61280b2b73e9f4aa1e4bc67908f;p=forks%2Fvmdebootstrap.git diff --git a/vmdebootstrap b/vmdebootstrap index ea5edff..5b4fa96 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -73,6 +73,11 @@ class VmDebootstrap(cliapp.Application): metavar='USER/PASSWORD') self.settings.boolean(['serial-console'], 'configure image to use a serial console') + self.settings.string(['serial-console-command'], + 'command to manage the serial console, appended ' + 'to /etc/inittab (%default)', + metavar='COMMAND', + default='/sbin/getty -L ttyS0 115200 vt100') self.settings.boolean(['sudo'], 'install sudo, and if user is created, add them ' 'to sudo group') @@ -102,6 +107,7 @@ class VmDebootstrap(cliapp.Application): self.set_hostname(rootdir) self.create_fstab(rootdir) self.install_debs(rootdir) + self.cleanup_apt_cache(rootdir) self.set_root_password(rootdir) self.create_users(rootdir) self.remove_udev_persistent_rules(rootdir) @@ -246,6 +252,10 @@ class VmDebootstrap(cliapp.Application): logging.debug('stdout:\n%s' % out) shutil.rmtree(tmp) + def cleanup_apt_cache(self, rootdir): + out = self.runcmd(['chroot', rootdir, 'apt-get', 'clean']) + logging.debug('stdout:\n%s' % out) + def set_root_password(self, rootdir): if self.settings['root-password']: self.message('Setting root password') @@ -345,10 +355,11 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s f.close() if self.settings['serial-console']: + serial_command = self.settings['serial-console-command'] logging.debug('adding getty to serial console') inittab = os.path.join(rootdir, 'etc/inittab') with open(inittab, 'a') as f: - f.write('\nS0:23:respawn:/sbin/getty -L ttyS0 115200 vt100\n') + f.write('\nS0:23:respawn:%s\n' % serial_command) self.runcmd(['extlinux', '--install', rootdir]) self.runcmd(['sync'])