From bb694671f26ea0327389a01fc695fd7dcefd5abf Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 26 Apr 2020 18:41:42 +0200 Subject: [PATCH] Attempt to stop containers in App update/uninstall, closes #3 --- APKBUILD | 2 +- usr/bin/spoc-container | 5 ++++- usr/lib/python3.8/spoc/app.py | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/APKBUILD b/APKBUILD index 56aae33..56e57e0 100644 --- a/APKBUILD +++ b/APKBUILD @@ -1,7 +1,7 @@ # Contributor: Disassembler # Maintainer: Disassembler pkgname=spoc -pkgver=0.0.1 +pkgver=0.9.2 pkgrel=0 pkgdesc="SPOC application, container, and image manager" url="https://spotter.vm/" diff --git a/usr/bin/spoc-container b/usr/bin/spoc-container index 4e725d2..901f79e 100755 --- a/usr/bin/spoc-container +++ b/usr/bin/spoc-container @@ -85,7 +85,10 @@ def modify(container_name, depends, mounts, env, uid, gid, cmd, cwd, ready, halt def destroy(container_name): # Remove container and its directory - Container(container_name, False).destroy() + container = Container(container_name, False) + if container.is_running(): + container.stop() + container.destroy() def start(container_name, command): # Start the container using init values from its definition diff --git a/usr/lib/python3.8/spoc/app.py b/usr/lib/python3.8/spoc/app.py index 80238e0..6cc3eb8 100644 --- a/usr/lib/python3.8/spoc/app.py +++ b/usr/lib/python3.8/spoc/app.py @@ -108,8 +108,10 @@ class App: repo_local.register_app(self.name, self.get_definition()) def update(self, observer=None): - # Remove containers + # Stop and remove containers for container in self.containers.copy(): + if container.is_running(): + container.stop() container.destroy() self.containers.remove(container) # Load online definition @@ -130,14 +132,13 @@ class App: repo_local.register_app(self.name, self.get_definition()) def uninstall(self, observer=None): - # Make sure the containers are stopped + # Stop and remove containers for container in self.containers: - container.stop() + if container.is_running(): + container.stop() + container.destroy() # Run uninstall script self.run_script('uninstall') - # Remove containers - for container in self.containers: - container.destroy() # Unregister app and remove scripts repo_local.unregister_app(self.name) try: