linux-tools/modules/install/ToolsInstaller.py

41 lines
1.8 KiB
Python
Raw Normal View History

import json
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'])
2020-03-10 23:02:33 +01:00
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'])
2020-03-10 23:02:33 +01:00
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)
print("Set up docker apt-key")
subprocess.run("apt-get update", shell=True)
subprocess.run("apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common", shell=True)
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)
print("Installing the Service")
subprocess.run("apt-get update", shell=True)
subprocess.run("apt-get install docker-ce docker-ce-cli containerd.io", shell=True)
print("Checking the installation")
subprocess.run("docker run hello-world", shell=True)