feat: do not require running containers

This commit is contained in:
Rudra B.S. 2024-02-09 15:57:30 +05:30
parent 5c08c1a111
commit 0413532282
3 changed files with 14 additions and 18 deletions

14
blend
View file

@ -136,7 +136,7 @@ def check_container_status(name):
return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"") return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"")
def core_start_container(name): def core_start_container(name, new_container=False):
subprocess.call(['podman', 'start', name], subprocess.call(['podman', 'start', name],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
@ -161,6 +161,10 @@ def core_create_container():
distro = args.distro distro = args.distro
info(f'creating container {name}, using {distro}') info(f'creating container {name}, using {distro}')
if check_container(name):
error(f'container {name} already exists')
exit(1)
podman_command = [] podman_command = []
# Basic stuff # Basic stuff
@ -213,9 +217,6 @@ def core_create_container():
ret = subprocess.run(podman_command).returncode ret = subprocess.run(podman_command).returncode
if ret != 0: if ret != 0:
if check_container(name):
error(f'container {name} already exists')
exit(1)
error(f'failed to create container {name}') error(f'failed to create container {name}')
exit(1) exit(1)
@ -381,6 +382,9 @@ def update_blends():
def enter_container(): def enter_container():
if check_container_status(args.container_name) != 'running':
core_start_container(args.container_name)
podman_args = ['--env', 'LC_ALL=C.UTF-8'] podman_args = ['--env', 'LC_ALL=C.UTF-8']
sudo = [] sudo = []
if os.environ.get('SUDO_USER') == None: if os.environ.get('SUDO_USER') == None:
@ -461,7 +465,7 @@ if os.geteuid() == 0 and os.environ['BLEND_ALLOW_ROOT'] == None:
description = f''' description = f'''
{colors.bold}{colors.fg.purple}Version:{colors.reset} {__version}{colors.bold} {colors.bold}{colors.fg.purple}Version:{colors.reset} {__version}{colors.bold}
Use the 'blendOS Settings' app to create and manage Linux containers, Android apps and immutability configuration. Use the 'blendOS Settings' app to create and manage Linux containers, Android apps and for system configuration.
You can install and submit web apps from the Web Store. You can install and submit web apps from the Web Store.
''' '''

View file

@ -1,7 +1,7 @@
<html> <html>
<head> <head>
<title>Settings</title> <title>Linux Containers</title>
<!-- Import bootstrap v5.0. --> <!-- Import bootstrap v5.0. -->
<link href="external/css/bootstrap.min.css" rel="stylesheet"> <link href="external/css/bootstrap.min.css" rel="stylesheet">
@ -18,7 +18,7 @@
Containers</button> Containers</button>
<button class="btn btn-outline-light shadow-none d-none" id="android-button" onclick="page('android')">Android <button class="btn btn-outline-light shadow-none d-none" id="android-button" onclick="page('android')">Android
Apps</button> Apps</button>
<button class="btn btn-outline-light shadow-none" id="system-button" onclick="page('system')">System</button> <button class="btn btn-outline-light shadow-none" id="system-button" onclick="page('system')">System Updates</button>
</div> </div>
</div> </div>

View file

@ -1,6 +1,6 @@
<div class="container-fluid d-flex justify-content-center"> <div class="container-fluid d-flex justify-content-center">
<div class="col-12 col-lg-10 col-xl-8 mx-auto"> <div class="col-12 col-lg-10 col-xl-8 mx-auto">
<strong class="mb-0">System Settings</strong> <strong class="mb-0">System Updates</strong>
<div style="height: 0.75rem;"></div> <div style="height: 0.75rem;"></div>
<div class="list-group mb-3 shadow"> <div class="list-group mb-3 shadow">
<div class="list-group-item d-none" id="app-grouping-item"> <div class="list-group-item d-none" id="app-grouping-item">
@ -22,14 +22,6 @@
</div> </div>
</div> </div>
<div class="container-fluid d-flex justify-content-center">
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
<p>
You can install packages just like you would on a regular Arch system, or install them in containers.
</p>
</div>
</div>
<!-- Import generic page JS. --> <!-- Import generic page JS. -->
<script src="internal/js/generic_page.js"></script> <script src="internal/js/generic_page.js"></script>