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!
Browse Source

Added support for chown, chmod and zfs props in volume compose.

master
parent
commit
ac5b6f7ac8
2 changed files with 23 additions and 11 deletions
  1. +5
    -1
      example/gitea/focker-compose.yml
  2. +18
    -10
      focker/compose.py

+ 5
- 1
example/gitea/focker-compose.yml View File

@@ -6,7 +6,11 @@ images:
certbot-latest: ../certbot
volumes:
gitea-data: {}
gitea-data:
chmod: 0750
chown: 211:211
zfs:
quota: 5G
certbot-webroot: {}
certbot-config-gitea: {}


+ 18
- 10
focker/compose.py View File

@@ -12,7 +12,8 @@ from .zfs import AmbiguousValueError, \
zfs_tag, \
zfs_untag, \
zfs_mountpoint, \
zfs_poolname
zfs_poolname, \
zfs_set_props
from .jail import jail_fs_create, \
jail_create, \
jail_remove
@@ -25,19 +26,26 @@ import os
def build_volumes(spec):
poolname = zfs_poolname()
for tag in spec.keys():
for tag, params in spec.items():
name = None
try:
name, _ = zfs_find(tag, focker_type='volume')
continue
except AmbiguousValueError:
raise
except ValueError:
pass
sha256 = random_sha256_hexdigest()
name = find_prefix(poolname + '/focker/volumes/', sha256)
subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
zfs_untag([ tag ], focker_type='volume')
zfs_tag(name, [ tag ])
if name is None:
sha256 = random_sha256_hexdigest()
name = find_prefix(poolname + '/focker/volumes/', sha256)
subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
zfs_untag([ tag ], focker_type='volume')
zfs_tag(name, [ tag ])
mountpoint = zfs_mountpoint(name)
print('params:', params)
if 'chown' in params:
os.chown(mountpoint, *map(int, params['chown'].split(':')))
if 'chmod' in params:
os.chmod(mountpoint, params['chmod'])
if 'zfs' in params:
zfs_set_props(name, params['zfs'])
def build_images(spec, path):


Loading…
Cancel
Save