diff --git a/dangerzone/__init__.py b/dangerzone/__init__.py index 6d3d2d0..be8ed79 100644 --- a/dangerzone/__init__.py +++ b/dangerzone/__init__.py @@ -40,7 +40,7 @@ class Application(QtWidgets.QApplication): @click.command() -@click.option("--custom-container") # Use this container instead of flmcode/dangerzone +@click.option("--custom-container") # Use this container instead of flmcode/dangerzone @click.argument("filename", required=False) def main(custom_container, filename): click.echo(f"dangerzone {dangerzone_version}") @@ -75,6 +75,9 @@ def main(custom_container, filename): if not global_common.ensure_user_is_in_docker_group(): click.echo("Failed to add user to docker group") return + if not global_common.ensure_docker_service_is_started(): + click.echo("Failed to start docker service") + return # See if we need to install Docker... if (platform.system() == "Darwin" or platform.system() == "Windows") and ( diff --git a/dangerzone/global_common.py b/dangerzone/global_common.py index 29c77e2..e8fd1e8 100644 --- a/dangerzone/global_common.py +++ b/dangerzone/global_common.py @@ -19,6 +19,7 @@ elif platform.system() == "Linux": from xdg.DesktopEntry import DesktopEntry from .settings import Settings +from .docker_installer import is_docker_ready class GlobalCommon(object): @@ -404,6 +405,31 @@ class GlobalCommon(object): return True + def ensure_docker_service_is_started(self): + if not is_docker_ready(self): + message = "Dangerzone requires Docker.

Docker should be installed, but it looks like it's not running in the background.

Click Ok to try starting the docker service. You will have to type your login password." + if Alert(self, message).launch(): + p = subprocess.run( + [ + "/usr/bin/pkexec", + self.get_resource_path("enable_docker_service.sh"), + ] + ) + if p.returncode == 0: + # Make sure docker is now ready + if is_docker_ready(self): + return True + else: + message = "Restarting docker appeared to work, but the service still isn't responding, quitting." + Alert(self, message).launch() + else: + message = "Failed to start the docker service, quitting." + Alert(self, message).launch() + + return False + + return True + def get_subprocess_startupinfo(self): if platform.system() == "Windows": startupinfo = subprocess.STARTUPINFO() diff --git a/share/enable_docker_service.sh b/share/enable_docker_service.sh new file mode 100755 index 0000000..8ce851f --- /dev/null +++ b/share/enable_docker_service.sh @@ -0,0 +1,3 @@ +#!/bin/sh +/usr/bin/systemctl restart docker +/usr/bin/systemctl enable docker \ No newline at end of file