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.

30 lines
1.3KB

  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. if args.empty and args.non_interactive:
  9. raise ValueError('--empty and --non-interactive are mutually exclusive')
  10. version = subprocess.check_output(['freebsd-version']).decode('utf-8')
  11. print('FreeBSD version:', version)
  12. tags = args.tags or [ 'freebsd-' + version.split('-')[0], 'freebsd-latest' ]
  13. sha256 = hashlib.sha256(('FreeBSD ' + version).encode('utf-8')).hexdigest()
  14. poolname = zfs_poolname()
  15. name = find_prefix(poolname + '/focker/images/', sha256)
  16. subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
  17. zfs_tag(name, tags)
  18. res = None
  19. if args.non_interactive:
  20. res = subprocess.run(['focker-bsdinstall', zfs_mountpoint(name)])
  21. elif not args.empty:
  22. res = subprocess.run(['bsdinstall', 'jail', zfs_mountpoint(name)])
  23. if res is not None and res.returncode != 0:
  24. zfs_run(['zfs', 'destroy', '-r', '-f', name])
  25. raise ValueError('bsdinstall failed')
  26. subprocess.check_output(['zfs', 'set', 'rdonly=on', name])
  27. subprocess.check_output(['zfs', 'snapshot', name + '@1'])