retry
This commit is contained in:
parent
9a0d199951
commit
cb5175f6de
|
@ -72,7 +72,7 @@ class BuildBase:
|
|||
infra_methods = [infra.BinaryFolders, infra.ChrootInstallerFiles,
|
||||
infra.ArchitectureFiles, infra.Archive,
|
||||
infra.InstallerFiles, infra.FusatoConfigs,
|
||||
infra.ServerConfigFiles,
|
||||
infra.ServerConfigFiles
|
||||
]
|
||||
for method in infra_methods:
|
||||
method(self.sbase, self.sarch)
|
||||
|
|
|
@ -24,6 +24,15 @@ WPINSTALLER = "/fusato/config/includes.installer"
|
|||
BINARYPTH = "/fusato/config/includes.binary"
|
||||
BOOTSTRAP = "/fusato/config/includes.bootstrap"
|
||||
FUSATOCONFIG = "/fusato/config"
|
||||
BASE_CONFIG = {
|
||||
"debian": {
|
||||
"scripts_dir": "/server/scripts/debian/",
|
||||
},
|
||||
"devuan": {
|
||||
"scripts_dir": "/server/scripts/devuan/",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Set up the logging format
|
||||
logger = logging.getLogger()
|
||||
|
@ -145,11 +154,6 @@ class ChrootInstallerFiles:
|
|||
for base in bases:
|
||||
cls(base)
|
||||
|
||||
#### This section is not really needed since this file is never executed
|
||||
#### outright so I commented this
|
||||
#if __name__ == "__main__": ## This seems incorrect, I am testing
|
||||
# ChrootInstallerFiles.run_for_all_bases()
|
||||
|
||||
|
||||
class BinaryFolders:
|
||||
"""
|
||||
|
@ -314,40 +318,45 @@ class ServerConfigFiles:
|
|||
Class to handle copying server configuration files based on the sbase.
|
||||
"""
|
||||
|
||||
def __init__(self, sbase):
|
||||
def __init__(self, sbase, sarch, build_base):
|
||||
"""
|
||||
Initialize the ServerConfigFiles class.
|
||||
|
||||
Args:
|
||||
sbase (str): Server base (e.g., "debian", "devuan").
|
||||
sarch (str): Server architecture (e.g., "amd64", "arm64").
|
||||
build_base (BuildBase): Instance of BuildBase containing necessary context.
|
||||
"""
|
||||
self.sbase = sbase
|
||||
self.sarch = sarch
|
||||
self.build_base = build_base
|
||||
self.copy_server_config_files()
|
||||
|
||||
def copy_server_config_files(self):
|
||||
"""
|
||||
Copy server configuration files based on the sbase.
|
||||
"""
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info(f"Copying server configuration files for {self.sbase.capitalize()}")
|
||||
|
||||
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'),
|
||||
'welcome.sh',
|
||||
'configure_apache2.sh',
|
||||
'configure_firewalld.sh',
|
||||
'configure_hostname.sh',
|
||||
'configure_mariadb.sh',
|
||||
'configure_nginx.sh',
|
||||
'configure_php_and_docker.sh',
|
||||
'configure_postfix.sh',
|
||||
'configure_postgresql.sh',
|
||||
'configure_sqlite.sh',
|
||||
'configure_ssh.sh',
|
||||
'configure_static_ip.sh',
|
||||
'create_user.sh',
|
||||
'update_and_install.sh',
|
||||
]
|
||||
|
||||
des_paths = [
|
||||
|
@ -367,23 +376,26 @@ class ServerConfigFiles:
|
|||
'/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)
|
||||
for src_file, des_dir in zip(src_paths, des_paths):
|
||||
src_path = os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], src_file)
|
||||
des_path = os.path.join(self.build_base.HOME_FOLDER, self.build_base.WPCHROOT, des_dir, src_file)
|
||||
|
||||
logger.info(f"Copying {src_path} to {des_path}")
|
||||
try:
|
||||
shutil.copy2(src_path, des_path)
|
||||
if os.path.isdir(src_path):
|
||||
shutil.copytree(src_path, des_path, ignore_dangling_symlinks=True)
|
||||
else:
|
||||
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}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sbase = build_base.sbase
|
||||
sarch = build_base.sarch
|
||||
server_config_files = ServerConfigFiles(sbase, sarch, build_base)
|
||||
|
||||
class ArchitectureFiles:
|
||||
"""
|
||||
Copy all the needed files and folders to CHROOT. Depending on the
|
||||
|
|
Loading…
Reference in New Issue