From 554a3ed0546ce5cbc45c18dd013c0417e5bc5b0f Mon Sep 17 00:00:00 2001 From: Eike Date: Mon, 27 Feb 2023 20:49:25 +0100 Subject: [PATCH 1/2] initial commit --- jlmkr.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jlmkr.py b/jlmkr.py index 06bf24c..d49ceef 100644 --- a/jlmkr.py +++ b/jlmkr.py @@ -185,7 +185,7 @@ def start_jail(jail_name): print(dedent(f""" Starting jail with the following command: - + {shlex.join(cmd)} Starting jail with name: {jail_name} @@ -409,7 +409,7 @@ def create_jail(jail_name): print(dedent(f""" {YELLOW}{BOLD}WARNING: CHECK SYNTAX{NORMAL} - + You may pass additional flags to systemd-nspawn. With incorrect flags the jail may not start. It is possible to correct/add/remove flags post-install. @@ -497,7 +497,7 @@ def create_jail(jail_name): os.path.join(jail_rootfs_path, 'sbin/init'))) != "systemd": print(dedent(f""" {YELLOW}{BOLD}WARNING: DISTRO NOT SUPPORTED{NORMAL} - + Chosen distro appears not to use systemd... You probably will not get a shell with: @@ -628,6 +628,7 @@ def delete_jail(jail_name): def main(): + eprint("hello basti") if os.stat(__file__).st_uid != 0: fail("This script should be owned by the root user...") From dbb1c5f719cc3bbfabbcb4deb70e5cdeabfa7f26 Mon Sep 17 00:00:00 2001 From: Eike Date: Mon, 27 Feb 2023 22:01:36 +0100 Subject: [PATCH 2/2] delete feature added --- jlmkr.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 jlmkr.py diff --git a/jlmkr.py b/jlmkr.py old mode 100644 new mode 100755 index d49ceef..0240e12 --- a/jlmkr.py +++ b/jlmkr.py @@ -617,18 +617,21 @@ def delete_jail(jail_name): """ Delete jail with given name. """ - # stop the jail - os.system(f"machinectl stop {jail_name}") - jail_path = os.path.join(JAILS_DIR_PATH, jail_name) - if os.path.isdir(jail_path): - eprint(f"Cleaning up: {jail_path}") - shutil.rmtree(jail_path) + check = input(f"CAUTION: Type \"{jail_name}\" to confirm! \n") or "" + if check == jail_name: + if os.path.isdir(jail_path): + os.system(f"machinectl stop {jail_name}") + eprint(f"Cleaning up: {jail_path}") + shutil.rmtree(jail_path) + else: + eprint(f"A jail with name {jail_name} does not exist.") + else: + eprint("Wrong name, nothing happens.") def main(): - eprint("hello basti") if os.stat(__file__).st_uid != 0: fail("This script should be owned by the root user...")