2020-03-10 23:12:19 +01:00
|
|
|
import platform
|
2020-03-06 01:23:20 +01:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
2020-03-06 02:34:57 +01:00
|
|
|
class ToolsInstaller:
|
2020-03-06 01:23:20 +01:00
|
|
|
|
2020-03-06 02:34:57 +01:00
|
|
|
def basic_tools(self):
|
2020-03-06 01:23:20 +01:00
|
|
|
"""Install the most basic tools!"""
|
|
|
|
print("Try to install basic Command-line tools")
|
2020-03-11 00:41:17 +01:00
|
|
|
subprocess.run("apt-get install -y bleachbit nano xrdp htop bash-completion dialog powertop tree", shell=True)
|
2020-03-06 01:23:20 +01:00
|
|
|
print("Script ran to completion.")
|
|
|
|
|
|
|
|
def hard_drive_tools(self):
|
|
|
|
"""Install tools to look up smart information from your hard-drives"""
|
2020-03-11 00:41:17 +01:00
|
|
|
subprocess.run("apt-get install -y smartmontools gsmartcontrol", shell=True)
|
2020-03-10 23:02:33 +01:00
|
|
|
|
|
|
|
def docker(self):
|
|
|
|
"""Install the Docker service on the machine"""
|
|
|
|
print("Removing any old installations")
|
|
|
|
subprocess.run("apt-get remove docker docker-engine docker.io containerd runc", shell=True)
|
|
|
|
subprocess.run("apt-get update", shell=True)
|
2020-03-10 23:12:19 +01:00
|
|
|
subprocess.run(
|
|
|
|
"apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common",
|
|
|
|
shell=True)
|
2020-03-10 23:33:52 +01:00
|
|
|
|
|
|
|
print("Checking for entry in /etc/apt/sources.list")
|
|
|
|
with open("/etc/apt/sources.list") as apt_list:
|
|
|
|
line = apt_list.read()
|
|
|
|
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():
|
2020-03-11 00:16:39 +01:00
|
|
|
linux_distro = "ubuntu"
|
2020-03-10 23:33:52 +01:00
|
|
|
elif "debian" in platform.version().lower():
|
2020-03-11 00:16:39 +01:00
|
|
|
linux_distro = "debian"
|
|
|
|
else:
|
|
|
|
print("Version not supported by this installer")
|
|
|
|
return
|
2020-03-11 00:33:29 +01:00
|
|
|
|
|
|
|
base_url = f"https://download.docker.com/linux/{linux_distro}"
|
2020-03-11 00:16:39 +01:00
|
|
|
|
2020-03-11 00:29:55 +01:00
|
|
|
subprocess.run("curl -fsSL " + base_url + "/gpg | sudo apt-key add -", shell=True)
|
2020-03-11 00:16:39 +01:00
|
|
|
subprocess.run("apt-key fingerprint 0EBFCD88", shell=True)
|
2020-03-11 00:29:55 +01:00
|
|
|
subprocess.run("add-apt-repository \"deb [arch=amd64] " + base_url + " $(lsb_release -cs) stable\"",
|
2020-03-11 00:16:39 +01:00
|
|
|
shell=True)
|
2020-03-10 23:33:52 +01:00
|
|
|
else:
|
|
|
|
print("skip adding of the key")
|
|
|
|
|
2020-03-10 23:02:33 +01:00
|
|
|
print("Installing the Service")
|
|
|
|
subprocess.run("apt-get update", shell=True)
|
2020-03-10 23:12:19 +01:00
|
|
|
subprocess.run("apt-get install -y docker-ce docker-ce-cli containerd.io", shell=True)
|
2020-03-10 23:33:52 +01:00
|
|
|
|
2020-03-10 23:02:33 +01:00
|
|
|
print("Checking the installation")
|
2020-03-10 23:33:52 +01:00
|
|
|
subprocess.run("docker run --rm hello-world", shell=True)
|