63 lines
2.8 KiB
Python
63 lines
2.8 KiB
Python
import json
|
|
import platform
|
|
import subprocess
|
|
|
|
|
|
class ToolsInstaller:
|
|
|
|
def __init__(self):
|
|
with open("modules/install/programs.json") as config_file:
|
|
self.programs_json = json.load(config_file)
|
|
|
|
def basic_tools(self):
|
|
"""Install the most basic tools!"""
|
|
print("Try to install basic Command-line tools")
|
|
|
|
programs_list = " ".join(p for p in self.programs_json['basic-tools'])
|
|
subprocess.run("apt-get install" + programs_list, shell=True)
|
|
|
|
print("Script ran to completion.")
|
|
|
|
def hard_drive_tools(self):
|
|
"""Install tools to look up smart information from your hard-drives"""
|
|
programs_list = " ".join(p for p in self.programs_json['hard-drive'])
|
|
subprocess.run("apt-get install " + programs_list, shell=True)
|
|
|
|
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)
|
|
subprocess.run(
|
|
"apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common",
|
|
shell=True)
|
|
|
|
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():
|
|
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)
|
|
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)
|
|
else:
|
|
print("skip adding of the key")
|
|
|
|
print("Installing the Service")
|
|
subprocess.run("apt-get update", shell=True)
|
|
subprocess.run("apt-get install -y docker-ce docker-ce-cli containerd.io", shell=True)
|
|
|
|
print("Checking the installation")
|
|
subprocess.run("docker run --rm hello-world", shell=True)
|