feat: allow running binaries with sudo

This commit is contained in:
Rudra Saraswat 2024-02-10 10:24:51 +05:30
parent 9d93042e1f
commit f1bf3d7e1d

8
blend
View file

@ -128,11 +128,17 @@ def check_container(name):
def check_container_status(name): def check_container_status(name):
if os.environ.get('SUDO_USER') == None:
return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"") return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"")
else:
return host_get_output(f"sudo -u {os.environ.get('SUDO_USER')} podman inspect --type container " + name + " --format \"{{.State.Status}}\"")
def core_start_container(name, new_container=False): def core_start_container(name, new_container=False):
subprocess.call(['podman', 'start', name], sudo = []
if os.environ.get('SUDO_USER') != None:
sudo = ['sudo', '-u', os.environ.get('SUDO_USER')]
subprocess.call([*sudo, 'podman', 'start', name],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
start_time = time.time() - 1000 # workaround start_time = time.time() - 1000 # workaround