diff --git a/python/lib/setup.py b/python/lib/setup.py index cfc8050b..829c8e83 100755 --- a/python/lib/setup.py +++ b/python/lib/setup.py @@ -147,11 +147,6 @@ def check_ip(ip_to_check): ipaddress.ip_address(ip_to_check) -def check_root(): - if os.geteuid() != 0: - raise RuntimeError("root access is required!") - - # Easier than os.walk() + shutil.chown() def chown(new_user, folder): lib.utils.run(['chown', '-R', f"{new_user}:{new_user}", folder]) diff --git a/python/lib/utils.py b/python/lib/utils.py index 7e4b682e..3607b5ff 100755 --- a/python/lib/utils.py +++ b/python/lib/utils.py @@ -31,6 +31,11 @@ def call_git_loud(directory, cmd, **kwargs): return call_git(directory, cmd, **kwargs, capture_output=False) +def check_root(): + if os.geteuid() != 0: + raise RuntimeError("root access is required!") + + def chronic(*args, **kwargs): kwargs.setdefault('capture_output', True) diff --git a/python/setup/almalinux.py b/python/setup/almalinux.py index ff609005..1fdd0a7f 100755 --- a/python/setup/almalinux.py +++ b/python/setup/almalinux.py @@ -18,7 +18,7 @@ def get_alma_version(): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() alma_version = get_alma_version() if alma_version not in (9, ): raise RuntimeError( diff --git a/python/setup/alpine.py b/python/setup/alpine.py index 17640874..a6f97847 100755 --- a/python/setup/alpine.py +++ b/python/setup/alpine.py @@ -150,7 +150,7 @@ def setup_podman(user_name): if not (password := args.user_password): password = getpass.getpass(prompt='Password for Alpine user account: ') - lib.setup.check_root() + lib.utils.check_root() enable_community_repo() update_and_install_packages() setup_user(args.user_name, password) diff --git a/python/setup/arch.py b/python/setup/arch.py index 8fe14af6..21b7ee23 100755 --- a/python/setup/arch.py +++ b/python/setup/arch.py @@ -649,7 +649,7 @@ def parse_arguments(): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() def setup_doas(username): diff --git a/python/setup/debian.py b/python/setup/debian.py index b3664408..e11353cf 100755 --- a/python/setup/debian.py +++ b/python/setup/debian.py @@ -64,7 +64,7 @@ def pi_setup(user_name): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() supported_versions = ( 'bullseye', diff --git a/python/setup/equinix.py b/python/setup/equinix.py index 04f58401..f5957319 100755 --- a/python/setup/equinix.py +++ b/python/setup/equinix.py @@ -111,7 +111,7 @@ def parse_arguments(): if __name__ == '__main__': args = parse_arguments() - lib.setup.check_root() + lib.utils.check_root() drive = args.drive folder = Path(args.folder) diff --git a/python/setup/fedora.py b/python/setup/fedora.py index 0bb06a41..d0c33a82 100755 --- a/python/setup/fedora.py +++ b/python/setup/fedora.py @@ -111,7 +111,7 @@ def machine_is_trusted(): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() if (fedora_version := get_fedora_version()) not in range(MIN_FEDORA_VERSION, MAX_FEDORA_VERSION + 1): raise RuntimeError( diff --git a/python/setup/rocky.py b/python/setup/rocky.py index 0c125df0..bd2e4010 100755 --- a/python/setup/rocky.py +++ b/python/setup/rocky.py @@ -18,7 +18,7 @@ def get_rocky_version(): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() rocky_version = get_rocky_version() if rocky_version not in (9, ): raise RuntimeError( diff --git a/python/setup/ubuntu.py b/python/setup/ubuntu.py index 1b9996a8..e309e03f 100755 --- a/python/setup/ubuntu.py +++ b/python/setup/ubuntu.py @@ -28,7 +28,7 @@ def parse_arguments(): def prechecks(): - lib.setup.check_root() + lib.utils.check_root() supported_versions = ('focal', 'jammy', 'kinetic') if (codename := lib.setup.get_version_codename()) not in supported_versions: