diff --git a/python_modules/build_iso.py b/python_modules/build_iso.py index c56b615d..b4ab88a4 100644 --- a/python_modules/build_iso.py +++ b/python_modules/build_iso.py @@ -72,6 +72,7 @@ class BuildBase: infra_methods = [infra.BinaryFolders, infra.ChrootInstallerFiles, infra.ArchitectureFiles, infra.Archive, infra.InstallerFiles, infra.FusatoConfigs, + infra.ServerConfigFiles, ] for method in infra_methods: method(self.sbase, self.sarch) diff --git a/python_modules/infra.py b/python_modules/infra.py index 3ecfc35e..273f57f7 100644 --- a/python_modules/infra.py +++ b/python_modules/infra.py @@ -309,6 +309,80 @@ def mini_shared_installer_files(): shutil.copy(src_path, des_path) logger.info(f"Copy completed: {des_path}") +class ServerConfigFiles: + """ + Class to handle copying server configuration files based on the sbase. + """ + + def __init__(self, sbase): + """ + Initialize the ServerConfigFiles class. + """ + self.sbase = sbase + self.copy_server_config_files() + + def copy_server_config_files(self): + """ + Copy server configuration files based on the sbase. + """ + logger = logging.getLogger(__name__) + + if self.sbase not in BASE_CONFIG: + logger.error(f"Unsupported base: {self.sbase}") + return + + logger.info(f"Copy Server Configuration Files for {self.sbase.capitalize()}") + + src_paths = [ + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'welcome.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_apache2.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_firewalld.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_hostname.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_mariadb.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_nginx.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_php_and_docker.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_postfix.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_postgresql.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_sqlite.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_ssh.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_static_ip.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'create_user.sh'), + os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'update_and_install.sh'), + ] + + des_paths = [ + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + '/usr/local/bin', + ] + + src_q = collections.deque(src_paths) + des_q = collections.deque(des_paths) + + while src_q and des_q: + src = src_q.popleft() + des = des_q.popleft() + src_path = os.path.join(os.environ['HOME'], src) + des_path = os.path.join(os.environ['HOME'], WPCHROOT, des) + + logger.info(f"Copying {src_path} to {des_path}") + try: + shutil.copy2(src_path, des_path) + except Exception as e: + logger.error(f"Error copying {src_path} to {des_path}: {e}") + else: + logger.info(f"Successfully copied {src_path} to {des_path}") class ArchitectureFiles: """ @@ -620,79 +694,6 @@ def shared_server_files(): ) logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des) -# Configuration constants for directory paths -BASE_CONFIG = { - "debian": { - "scripts_dir": "/server/scripts/debian/", - }, - "devuan": { - "scripts_dir": "/server/scripts/devuan/", - } -} - -def server_config_files(sbase): - """ - This function copies specific server build files adapted for the provided base (sbase). - """ - logger = logging.getLogger(__name__) - - if sbase not in BASE_CONFIG: - logger.error(f"Unsupported base: {sbase}") - return - - logger.info(f"Copy Shared Files for {sbase.capitalize()}") - - src_paths = [ - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'welcome.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_apache2.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_firewalld.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_hostname.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_mariadb.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_nginx.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_php_and_docker.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_postfix.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_postgresql.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_sqlite.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_ssh.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'configure_static_ip.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'create_user.sh'), - os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'update_and_install.sh'), - ] - - des_paths = [ - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - '/usr/local/bin', - ] - - src_q = collections.deque(src_paths) - des_q = collections.deque(des_paths) - - while src_q and des_q: - src = src_q.popleft() - des = des_q.popleft() - src_path = os.path.join(os.environ['HOME'], src) - des_path = os.path.join(os.environ['HOME'], WPCHROOT, des) - - logger.info(f"Copying {src_path} to {des_path}") - try: - shutil.copy2(src_path, des_path) - except Exception as e: - logger.error(f"Error copying {src_path} to {des_path}: {e}") - else: - logger.info(f"Successfully copied {src_path} to {des_path}") - def boostrap_shared(): """ Copy specific folders in the boostrap location