mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
If docker service is not running, try to start it
This commit is contained in:
parent
7e398e2b28
commit
0b1cd9e9ef
3 changed files with 33 additions and 1 deletions
|
@ -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 (
|
||||
|
|
|
@ -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 = "<b>Dangerzone requires Docker.</b><br><br>Docker should be installed, but it looks like it's not running in the background.<br><br>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()
|
||||
|
|
3
share/enable_docker_service.sh
Executable file
3
share/enable_docker_service.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
/usr/bin/systemctl restart docker
|
||||
/usr/bin/systemctl enable docker
|
Loading…
Reference in a new issue