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

Trying to make sure you can Ctrl+C at any time

tags/0.92
parent
commit
a9f833b254
4 changed files with 13 additions and 7 deletions
  1. +2
    -0
      Fockerfile
  2. +2
    -2
      image.py
  3. +5
    -1
      jail.py
  4. +4
    -4
      snapshot.py

+ 2
- 0
Fockerfile View File

@@ -9,3 +9,5 @@ steps:
- copy: - copy:
- [ '/tmp/x', '/etc/x' ] - [ '/tmp/x', '/etc/x' ]
- [ 'focker-compose.yml', '/etc/focker-compose.yml' ] - [ 'focker-compose.yml', '/etc/focker-compose.yml' ]
- run: |
pkg install py37-certbot

+ 2
- 2
image.py View File

@@ -47,11 +47,11 @@ def build(spec, args):
name = root + '/' + st_sha256[:pre] name = root + '/' + st_sha256[:pre]
if not zfs_exists(name): if not zfs_exists(name):
break break
snap_name = new_snapshot(base, lambda: st.execute(zfs_mountpoint(name), args=args), name)
feed = { feed = {
'focker:sha256': st_sha256 'focker:sha256': st_sha256
} }
zfs_set_props(name, feed)
snap_name = new_snapshot(base, lambda: st.execute(zfs_mountpoint(name), args=args) and zfs_set_props(name, feed), name)
# zfs_set_props(name, feed)
# zfs_set_props(snap_name, feed) # zfs_set_props(snap_name, feed)
base = snap_name base = snap_name
base_sha256 = st_sha256 base_sha256 = st_sha256


+ 5
- 1
jail.py View File

@@ -7,8 +7,12 @@ import shutil
def jail_run(path, command): def jail_run(path, command):
command = ['jail', '-c', 'host.hostname=' + os.path.split(path)[1], 'mount.devfs=1', 'interface=lo1', 'ip4.addr=127.0.1.0', 'path=' + path, 'command', '/bin/sh', '-c', command] command = ['jail', '-c', 'host.hostname=' + os.path.split(path)[1], 'mount.devfs=1', 'interface=lo1', 'ip4.addr=127.0.1.0', 'path=' + path, 'command', '/bin/sh', '-c', command]
print('Running:', ' '.join(command)) print('Running:', ' '.join(command))
res = subprocess.run(command)
try:
res = subprocess.run(command)
finally:
subprocess.run(['umount', os.path.join(path, 'dev')])
if res.returncode != 0: if res.returncode != 0:
subprocess.run(['umount', os.path.join(path, 'dev')])
raise RuntimeError('Command failed') raise RuntimeError('Command failed')


+ 4
- 4
snapshot.py View File

@@ -11,10 +11,10 @@ def new_snapshot(base, fun, name):
zfs_run(['zfs', 'clone', base, name]) zfs_run(['zfs', 'clone', base, name])
try: try:
fun() fun()
zfs_run(['zfs', 'set', 'readonly=on', name])
snap_name = name + '@1'
zfs_run(['zfs', 'snapshot', snap_name])
except: except:
zfs_run(['zfs', 'destroy', name])
zfs_run(['zfs', 'destroy', '-f', name])
raise raise
zfs_run(['zfs', 'set', 'readonly=on', name])
snap_name = name + '@1'
zfs_run(['zfs', 'snapshot', snap_name])
return snap_name return snap_name

Loading…
Cancel
Save