From e9f92af66f532f103867754a9f2f7d6247580eff Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Fri, 6 Mar 2020 01:23:20 +0100 Subject: [PATCH] Rename module, split program categories --- modules/command-line tools/__init__.py | 5 ----- modules/command-line tools/cmd_tools.py | 19 ----------------- modules/command-line tools/programs.json | 8 -------- modules/program-installer/__init__.py | 5 +++++ modules/program-installer/module.py | 26 ++++++++++++++++++++++++ modules/program-installer/programs.json | 16 +++++++++++++++ 6 files changed, 47 insertions(+), 32 deletions(-) delete mode 100644 modules/command-line tools/__init__.py delete mode 100644 modules/command-line tools/cmd_tools.py delete mode 100644 modules/command-line tools/programs.json create mode 100644 modules/program-installer/__init__.py create mode 100644 modules/program-installer/module.py create mode 100644 modules/program-installer/programs.json diff --git a/modules/command-line tools/__init__.py b/modules/command-line tools/__init__.py deleted file mode 100644 index 90465af..0000000 --- a/modules/command-line tools/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .cmd_tools import CmdToolsModule - - -def get_module(): - return CmdToolsModule() \ No newline at end of file diff --git a/modules/command-line tools/cmd_tools.py b/modules/command-line tools/cmd_tools.py deleted file mode 100644 index 0f7f66b..0000000 --- a/modules/command-line tools/cmd_tools.py +++ /dev/null @@ -1,19 +0,0 @@ -import json -import subprocess - -from AbstractModule import AbstractModule - - -class CmdToolsModule(AbstractModule): - def run(self): - print("Try to install basic Command-line tools") - - with open("modules/command-line tools/programs.json") as config_file: - programs_json = json.load(config_file) - programs_list = "" - for program in programs_json: - programs_list += " " + program - - subprocess.run("sudo apt install" + programs_list, shell=True) - - print("Script ran to completion.") diff --git a/modules/command-line tools/programs.json b/modules/command-line tools/programs.json deleted file mode 100644 index d5a8228..0000000 --- a/modules/command-line tools/programs.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "bleachbit", - "nano", - "xrdp", - "htop", - "bash-completion", - "dialog" -] \ No newline at end of file diff --git a/modules/program-installer/__init__.py b/modules/program-installer/__init__.py new file mode 100644 index 0000000..cb3e108 --- /dev/null +++ b/modules/program-installer/__init__.py @@ -0,0 +1,5 @@ +from .module import CmdToolsModule + + +def get_module(): + return CmdToolsModule() diff --git a/modules/program-installer/module.py b/modules/program-installer/module.py new file mode 100644 index 0000000..d798e95 --- /dev/null +++ b/modules/program-installer/module.py @@ -0,0 +1,26 @@ +import json +import subprocess + +from AbstractModule import AbstractModule + + +class CmdToolsModule(AbstractModule): + + def __init__(self): + super().__init__() + with open("modules/program-installer/programs.json") as config_file: + self.programs_json = json.load(config_file) + + def run(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 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 install " + programs_list, shell=True) diff --git a/modules/program-installer/programs.json b/modules/program-installer/programs.json new file mode 100644 index 0000000..8a225c5 --- /dev/null +++ b/modules/program-installer/programs.json @@ -0,0 +1,16 @@ +{ + "basic-tools": [ + "bleachbit", + "nano", + "xrdp", + "htop", + "bash-completion", + "dialog", + "powertop", + "tree" + ], + "hard-drive": [ + "smartmontools", + "gsmartcontrol" + ] +} \ No newline at end of file