IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
916B

  1. import subprocess
  2. import hashlib
  3. from .misc import find_prefix
  4. from .zfs import zfs_poolname, \
  5. zfs_mountpoint, \
  6. zfs_tag
  7. def command_bootstrap(args):
  8. version = subprocess.check_output(['freebsd-version']).decode('utf-8')
  9. print('FreeBSD version:', version)
  10. tags = [ 'freebsd-' + version.split('-')[0], 'freebsd-latest' ]
  11. sha256 = hashlib.sha256(('FreeBSD ' + version).encode('utf-8')).hexdigest()
  12. poolname = zfs_poolname()
  13. name = find_prefix(poolname + '/focker/images/', sha256)
  14. subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
  15. zfs_tag(name, tags)
  16. res = subprocess.run(['bsdinstall', 'jail', zfs_mountpoint(name)])
  17. if res.returncode != 0:
  18. raise ValueError('bsdinstall failed')
  19. subprocess.check_output(['zfs', 'set', 'rdonly=on', name])
  20. subprocess.check_output(['zfs', 'snapshot', name + '@1'])