From df127f63e2153e51ffdd89a64be09c58dff43585 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 11 Mar 2020 00:16:39 +0100 Subject: [PATCH] Dynamically adjust url and gpg key --- modules/install/ToolsInstaller.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/install/ToolsInstaller.py b/modules/install/ToolsInstaller.py index 3d30e97..42e8156 100644 --- a/modules/install/ToolsInstaller.py +++ b/modules/install/ToolsInstaller.py @@ -38,19 +38,22 @@ class ToolsInstaller: if "download.docker.com/linux/" not in line.lower(): print("apt-repo is not installed, setting up docker apt-key") if "ubuntu" in platform.version().lower(): - subprocess.run("curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -", - shell=True) - subprocess.run("apt-key fingerprint 0EBFCD88", shell=True) - subprocess.run("add-apt-repository " - "\"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"", - shell=True) + linux_distro = "ubuntu" elif "debian" in platform.version().lower(): - subprocess.run("curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -", - shell=True) - subprocess.run("apt-key fingerprint 0EBFCD88", shell=True) - subprocess.run("add-apt-repository " - "\"deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable\"", - shell=True) + linux_distro = "debian" + else: + print("Version not supported by this installer") + return + + subprocess.run("curl -fsSL " + f"https://download.docker.com/linux/${linux_distro}/gpg " + "| sudo apt-key add -", + shell=True) + subprocess.run("apt-key fingerprint 0EBFCD88", shell=True) + subprocess.run("add-apt-repository \"deb [arch=amd64] " + f"https://download.docker.com/linux/${linux_distro}" + "$(lsb_release -cs) stable\"", + shell=True) else: print("skip adding of the key")