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!
Przeglądaj źródła

Added focker bootstrap command.

tags/0.92
rodzic
commit
b2201e6570
2 zmienionych plików z 26 dodań i 0 usunięć
  1. +22
    -0
      focker/bootstrap.py
  2. +4
    -0
      focker/focker.py

+ 22
- 0
focker/bootstrap.py Wyświetl plik

@@ -0,0 +1,22 @@
import subprocess
import hashlib
from .misc import find_prefix
from .zfs import zfs_poolname, \
zfs_mountpoint, \
zfs_tag
def command_bootstrap(args):
version = subprocess.check_output(['freebsd-version']).decode('utf-8')
print('FreeBSD version:', version)
tags = [ 'freebsd-' + version.split('-')[0], 'freebsd-latest' ]
sha256 = hashlib.sha256(('FreeBSD ' + version).encode('utf-8')).hexdigest()
poolname = zfs_poolname()
name = find_prefix(poolname + '/focker/images/', sha256)
subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
zfs_tag(name, tags)
res = subprocess.run(['bsdinstall', 'jail', zfs_mountpoint(name)])
if res.returncode != 0:
raise ValueError('bsdinstall failed')
subprocess.check_output(['zfs', 'set', 'rdonly=on', name])
subprocess.check_output(['zfs', 'snapshot', name + '@1'])

+ 4
- 0
focker/focker.py Wyświetl plik

@@ -37,6 +37,7 @@ from .jail import command_jail_create, \
from .compose import \
command_compose_build, \
command_compose_run
from .bootstrap import command_bootstrap
class ListForwarderFunctor(object):
@@ -71,6 +72,9 @@ def create_parser():
subparsers_top = parser_top.add_subparsers(dest='L1_command')
subparsers_top.required = True
parser = ListForwarder([subparsers_top.add_parser(cmd) for cmd in ['bootstrap', 'boot', 'bs']])
parser.set_defaults(func=command_bootstrap)
# image
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \
for cmd in ['image', 'ima', 'img', 'im', 'i'] ])


Ładowanie…
Anuluj
Zapisz