forked from sh-edraft.de/sh_linux_installation_scripts
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			39cdd989f0
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 359d333add | |||
| 51c852a839 | |||
| e4c585d4c5 | |||
| e017462416 | |||
| c2fc611f94 | 
							
								
								
									
										19
									
								
								src/multi_install/abc/application_menu_service_abc.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/multi_install/abc/application_menu_service_abc.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | from abc import ABC, abstractmethod | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ApplicationMenuServiceABC(ABC): | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def __init__(self): pass | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def install_application(self): pass | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def uninstall_application(self): pass | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def add_application(self): pass | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def remove_application(self): pass | ||||||
							
								
								
									
										7
									
								
								src/multi_install/abc/collection_service_abc.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/multi_install/abc/collection_service_abc.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | from abc import ABC, abstractmethod | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class CollectionServiceABC(ABC): | ||||||
|  |  | ||||||
|  |     @abstractmethod | ||||||
|  |     def __init__(self): pass | ||||||
| @@ -10,10 +10,7 @@ class MenuServiceABC(ABC): | |||||||
|     def run(self): pass |     def run(self): pass | ||||||
|      |      | ||||||
|     @abstractmethod |     @abstractmethod | ||||||
|     def select_os(self) -> str: pass |     def select_os(self) -> bool: pass | ||||||
|      |      | ||||||
|     @abstractmethod |     @abstractmethod | ||||||
|     def main_menu(self) -> str: pass |     def main_menu(self) -> bool: pass | ||||||
|      |  | ||||||
|     @abstractmethod |  | ||||||
|     def select_collection(self) -> str: pass |  | ||||||
|   | |||||||
							
								
								
									
										39
									
								
								src/multi_install/config/application_list_settings.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/multi_install/config/application_list_settings.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | |||||||
|  | import traceback | ||||||
|  |  | ||||||
|  | from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC | ||||||
|  | from cpl_core.console import Console | ||||||
|  |  | ||||||
|  | from multi_install.config.application_settings import ApplicationSettings | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ApplicationListSettings(ConfigurationModelABC): | ||||||
|  |  | ||||||
|  |     def __init__(self): | ||||||
|  |         ConfigurationModelABC.__init__(self) | ||||||
|  |  | ||||||
|  |         self._debian_apps = [] | ||||||
|  |         self._red_hat_apps = [] | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def debian_apps(self) -> str: | ||||||
|  |         return self._debian_apps | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def redhat_apps(self) -> str: | ||||||
|  |         return self._debian_apps | ||||||
|  |  | ||||||
|  |     def from_dict(self, settings: dict): | ||||||
|  |         try: | ||||||
|  |              | ||||||
|  |             for app_cfg in settings['Debian']: | ||||||
|  |                 app = ApplicationSettings() | ||||||
|  |                 app.from_dict(app_cfg) | ||||||
|  |                 self._debian_apps.append(app) | ||||||
|  |                      | ||||||
|  |             for app_cfg in settings['RedHat']: | ||||||
|  |                 app = ApplicationSettings() | ||||||
|  |                 app.from_dict(app_cfg) | ||||||
|  |                 self._red_hat_apps.append(app) | ||||||
|  |         except Exception as e: | ||||||
|  |             Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') | ||||||
|  |             Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') | ||||||
							
								
								
									
										36
									
								
								src/multi_install/config/application_settings.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/multi_install/config/application_settings.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | import traceback | ||||||
|  | from typing import Optional | ||||||
|  |  | ||||||
|  | from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC | ||||||
|  | from cpl_core.console import Console | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ApplicationSettings(ConfigurationModelABC): | ||||||
|  |  | ||||||
|  |     def __init__(self): | ||||||
|  |         ConfigurationModelABC.__init__(self) | ||||||
|  |  | ||||||
|  |         self._name = '' | ||||||
|  |         self._repository = '' | ||||||
|  |         self._source_url = '' | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def name(self) -> str: | ||||||
|  |         return self._name | ||||||
|  |      | ||||||
|  |     @property | ||||||
|  |     def repository(self) -> str: | ||||||
|  |         return self._repository | ||||||
|  |      | ||||||
|  |     @property | ||||||
|  |     def source_url(self) -> Optional[str]: | ||||||
|  |         return self._source_url(self) | ||||||
|  |  | ||||||
|  |     def from_dict(self, settings: dict): | ||||||
|  |         try: | ||||||
|  |             self._name = settings['Name'] | ||||||
|  |             self._repository = settings['Repository'] if 'Repository' in settings else None | ||||||
|  |             self._source_url = settings['SourceUrl'] if 'SourceUrl' in settings else None | ||||||
|  |         except Exception as e: | ||||||
|  |             Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') | ||||||
|  |             Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') | ||||||
							
								
								
									
										1
									
								
								src/multi_install/model/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/multi_install/model/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | # imports | ||||||
							
								
								
									
										19
									
								
								src/multi_install/model/main_menu_enum.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/multi_install/model/main_menu_enum.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | from enum import Enum | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class MainMenuEnum(Enum): | ||||||
|  |  | ||||||
|  |     list_collection = 'List collection' | ||||||
|  |     install_collection = 'Install collection' | ||||||
|  |     uninstall_collection = 'Uninstall collection' | ||||||
|  |     add_collection = 'Add collection' | ||||||
|  |     remove_collection = 'Remove collection' | ||||||
|  |      | ||||||
|  |     list_application = 'List application' | ||||||
|  |     install_application = 'Install application' | ||||||
|  |     uninstall_application = 'Uninstall application' | ||||||
|  |     add_application = 'Add application' | ||||||
|  |     remove_application = 'Remove application' | ||||||
|  |      | ||||||
|  |     back = 'Back' | ||||||
|  |     exit = 'Exit' | ||||||
							
								
								
									
										16
									
								
								src/multi_install/service/application_menu_service.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/multi_install/service/application_menu_service.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | from multi_install.abc.application_menu_service_abc import ApplicationMenuServiceABC | ||||||
|  | from multi_install.config.application_list_settings import ApplicationListSettings | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ApplicationMenuService(ApplicationMenuServiceABC): | ||||||
|  |  | ||||||
|  |     def __init__(self, application_settings: ApplicationListSettings): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def install_application(self): pass | ||||||
|  |  | ||||||
|  |     def uninstall_application(self): pass | ||||||
|  |  | ||||||
|  |     def add_application(self): pass | ||||||
|  |  | ||||||
|  |     def remove_application(self): pass | ||||||
							
								
								
									
										7
									
								
								src/multi_install/service/collection_service.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/multi_install/service/collection_service.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | from multi_install.abc.collection_service_abc import CollectionServiceABC | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class CollectionService(CollectionServiceABC): | ||||||
|  |  | ||||||
|  |     def __init__(self): | ||||||
|  |         pass | ||||||
| @@ -4,6 +4,7 @@ from cpl_core.console import Console | |||||||
| from cpl_query.extension import List | from cpl_query.extension import List | ||||||
| from multi_install.abc.menu_service_abc import MenuServiceABC | from multi_install.abc.menu_service_abc import MenuServiceABC | ||||||
| from multi_install.config.os_settings import OSSettings | from multi_install.config.os_settings import OSSettings | ||||||
|  | from multi_install.model.main_menu_enum import MainMenuEnum | ||||||
|  |  | ||||||
|  |  | ||||||
| class MenuService(MenuServiceABC): | class MenuService(MenuServiceABC): | ||||||
| @@ -16,53 +17,77 @@ class MenuService(MenuServiceABC): | |||||||
|     def run(self): |     def run(self): | ||||||
|         is_end = False |         is_end = False | ||||||
|         while not is_end: |         while not is_end: | ||||||
|             self.select_os() |             is_end = self.select_os() | ||||||
|             main_menu = self.main_menu() |             if not is_end: | ||||||
|              |                 is_end = self.main_menu() | ||||||
|             if main_menu == 'Exit': |  | ||||||
|                 is_end = True |  | ||||||
|                  |                  | ||||||
|             elif main_menu == 'Back': |             if is_end: | ||||||
|                 break |                 Console.write_line() | ||||||
|          |          | ||||||
|     def select_os(self): |     def select_os(self) -> bool: | ||||||
|         Console.clear() |         Console.clear() | ||||||
|         options = List(str, self._os_settings.operating_systems.copy()) |         options = List(str, self._os_settings.operating_systems.copy()) | ||||||
|         options.append('Exit') |         options.append('Exit') | ||||||
|         Console.write_line('Select option:') |         Console.write_line('Select option:') | ||||||
|         options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}')) |         options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}')) | ||||||
|         os = int(Console.read('\n:')) |         os = 0 | ||||||
|  |         try: | ||||||
|  |             os = int(Console.read('\n:'))-1 | ||||||
|  |         except ValueError: | ||||||
|  |             Console.error('Input value must be int!') | ||||||
|  |             return True | ||||||
|  |          | ||||||
|         if os == options.index('Exit'): |         if os == options.index('Exit'): | ||||||
|             exit() |             return True | ||||||
|          |          | ||||||
|         self._os = os |         self._os = os | ||||||
|      |         return False | ||||||
|     def main_menu(self) -> str: |          | ||||||
|  |     def main_menu(self) -> bool: | ||||||
|         Console.clear() |         Console.clear() | ||||||
|         options = List(str, [ |         options = List(str, [ | ||||||
|             'Install collection', |             MainMenuEnum.install_collection.value, | ||||||
|             'Uninstall collection', |             MainMenuEnum.uninstall_collection.value, | ||||||
|             'Add collection', |             MainMenuEnum.add_collection.value, | ||||||
|             'Remove collection', |             MainMenuEnum.remove_collection.value, | ||||||
|              |              | ||||||
|             'Install application', |             MainMenuEnum.install_application.value, | ||||||
|             'Uninstall application', |             MainMenuEnum.uninstall_application.value, | ||||||
|             'Add application', |             MainMenuEnum.add_application.value, | ||||||
|             'Remove application', |             MainMenuEnum.remove_application.value, | ||||||
|             'Add application', |  | ||||||
|              |              | ||||||
|             'Back', |             MainMenuEnum.back.value, | ||||||
|             'Exit' |             MainMenuEnum.exit.value | ||||||
|         ]) |         ]) | ||||||
|         Console.write_line('Select option:') |         Console.write_line('Select option:') | ||||||
|         options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}')) |         options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}')) | ||||||
|         selected = int(Console.read('\n:')) |         selected = 0 | ||||||
|         if selected == options.index('Exit'): |         try: | ||||||
|             exit() |             selected = int(Console.read('\n:'))-1 | ||||||
|  |         except ValueError: | ||||||
|  |             Console.error('Input value must be int!') | ||||||
|  |             return True | ||||||
|          |          | ||||||
|         return selected |         # collection menu | ||||||
|      |         if selected == options.index(MainMenuEnum.list_collection.value): pass | ||||||
|     def select_collection(self) -> str:  |         elif selected == options.index(MainMenuEnum.install_collection.value): pass | ||||||
|         options = [] |         elif selected == options.index(MainMenuEnum.uninstall_collection.value): pass | ||||||
|         options.append('Exit') |         elif selected == options.index(MainMenuEnum.add_collection.value): pass | ||||||
|         return Console.select('>', 'Select collection:', options) |         elif selected == options.index(MainMenuEnum.remove_collection.value): pass | ||||||
|  |          | ||||||
|  |         # application menu | ||||||
|  |         elif selected == options.index(MainMenuEnum.list_application.value): pass | ||||||
|  |         elif selected == options.index(MainMenuEnum.install_application.value): pass | ||||||
|  |         elif selected == options.index(MainMenuEnum.uninstall_application.value): pass | ||||||
|  |         elif selected == options.index(MainMenuEnum.add_application.value): pass | ||||||
|  |         elif selected == options.index(MainMenuEnum.remove_application.value): pass | ||||||
|  |          | ||||||
|  |         elif selected == options.index(MainMenuEnum.back.value): | ||||||
|  |             return | ||||||
|  |         elif selected == options.index(MainMenuEnum.exit.value): | ||||||
|  |             return True | ||||||
|  |              | ||||||
|  |         else: | ||||||
|  |             raise Exception(f'Unknown option: {selected}') | ||||||
|  |          | ||||||
|  |         return False | ||||||
|   | |||||||
							
								
								
									
										98
									
								
								src/multi_install_cli/apps.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								src/multi_install_cli/apps.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | |||||||
|  | { | ||||||
|  |   "Application": { | ||||||
|  |     "RedHat": [], | ||||||
|  |     "Debian": [ | ||||||
|  |       { | ||||||
|  |         "Name": "brave-browser", | ||||||
|  |         "Deps": [ | ||||||
|  |           { | ||||||
|  |             "Name": "apt-transport-https" | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             "Name": "curl" | ||||||
|  |           } | ||||||
|  |         ] | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "barrier" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "gnome-boxes" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "google-chrome", | ||||||
|  |         "SourceUrl": "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "chrome-gnome-shell" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "discord", | ||||||
|  |         "SourceUrl": "https://discordapp.com/api/download?platform=linux&format=deb" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name:": "balena-etcher-electron" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "flameshot" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "geary" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "git" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "gnome-tweaks" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "gpick" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "kcolorchooser" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "keepassxc" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "lsd", | ||||||
|  |         "SourceUrl": "https://github.com/Peltoche/lsd/releases/download/0.19.0/lsd_0.19.0_amd64.deb" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "ncdu" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "neofetch" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "nextcloud-client", | ||||||
|  |         "Repository": "ppa:nextcloud-devs/client" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "signal-desktop" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "stacer" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "sublime-text", | ||||||
|  |         "Repository": "deb https://download.sublimetext.com/ apt/stable/" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "timeshift", | ||||||
|  |         "Repository": "ppa:teejee2008/ppa" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "trash-cli" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "ulauncher", | ||||||
|  |         "Repository": "ppa:agornostal/ulauncher" | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "Name": "code", | ||||||
|  |         "Repository": "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | ||||||
|  |       } | ||||||
|  |     ] | ||||||
|  |   } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user