@@ -65,6 +65,7 @@ def create_parser(): | |||||
parser.add_argument('--tags', '-t', type=str, nargs='+', default=[]) | parser.add_argument('--tags', '-t', type=str, nargs='+', default=[]) | ||||
parser.add_argument('--env', '-e', type=str, nargs='+', default=[]) | parser.add_argument('--env', '-e', type=str, nargs='+', default=[]) | ||||
parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[]) | parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[]) | ||||
parser.add_argument('--hostname', '-n', type=str) | |||||
parser = subparsers.add_parser('run') | parser = subparsers.add_parser('run') | ||||
parser.set_defaults(func=command_jail_run) | parser.set_defaults(func=command_jail_run) | ||||
@@ -87,6 +88,7 @@ def create_parser(): | |||||
parser = subparsers.add_parser('prune') | parser = subparsers.add_parser('prune') | ||||
parser.set_defaults(func=command_jail_prune) | parser.set_defaults(func=command_jail_prune) | ||||
parser.add_argument('--force', '-f', action='store_true') | |||||
# volume | # volume | ||||
subparsers = subparsers_top.add_parser('volume').add_subparsers() | subparsers = subparsers_top.add_parser('volume').add_subparsers() | ||||
@@ -17,7 +17,7 @@ def gen_env_command(command, env): | |||||
return command | return command | ||||
def jail_create(path, command, env, mounts, hostname): | |||||
def jail_create(path, command, env, mounts, hostname=None): | |||||
name = os.path.split(path)[-1] | name = os.path.split(path)[-1] | ||||
if os.path.exists('/etc/jail.conf'): | if os.path.exists('/etc/jail.conf'): | ||||
conf = jailconf.load('/etc/jail.conf') | conf = jailconf.load('/etc/jail.conf') | ||||
@@ -159,7 +159,8 @@ def command_jail_create(args): | |||||
{ a.split(':')[0]: ':'.join(a.split(':')[1:]) \ | { a.split(':')[0]: ':'.join(a.split(':')[1:]) \ | ||||
for a in args.env }, | for a in args.env }, | ||||
[ [a.split(':')[0], ':'.join(a.split(':')[1:])] \ | [ [a.split(':')[0], ':'.join(a.split(':')[1:])] \ | ||||
for a in args.mounts ] ) | |||||
for a in args.mounts ], | |||||
args.hostname ) | |||||
print(sha256) | print(sha256) | ||||
print(path) | print(path) | ||||
@@ -213,5 +214,5 @@ def command_jail_prune(args): | |||||
used.add(j['path']) | used.add(j['path']) | ||||
lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,name'], focker_type='jail') | lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,name'], focker_type='jail') | ||||
for j in lst: | for j in lst: | ||||
if j[1] == '-' and j[2] not in used: | |||||
if j[1] == '-' and (j[2] not in used or args.force): | |||||
jail_remove(j[2]) | jail_remove(j[2]) |