retry
This commit is contained in:
parent
9a0d199951
commit
cb5175f6de
|
@ -72,7 +72,7 @@ class BuildBase:
|
||||||
infra_methods = [infra.BinaryFolders, infra.ChrootInstallerFiles,
|
infra_methods = [infra.BinaryFolders, infra.ChrootInstallerFiles,
|
||||||
infra.ArchitectureFiles, infra.Archive,
|
infra.ArchitectureFiles, infra.Archive,
|
||||||
infra.InstallerFiles, infra.FusatoConfigs,
|
infra.InstallerFiles, infra.FusatoConfigs,
|
||||||
infra.ServerConfigFiles,
|
infra.ServerConfigFiles
|
||||||
]
|
]
|
||||||
for method in infra_methods:
|
for method in infra_methods:
|
||||||
method(self.sbase, self.sarch)
|
method(self.sbase, self.sarch)
|
||||||
|
|
|
@ -24,6 +24,15 @@ WPINSTALLER = "/fusato/config/includes.installer"
|
||||||
BINARYPTH = "/fusato/config/includes.binary"
|
BINARYPTH = "/fusato/config/includes.binary"
|
||||||
BOOTSTRAP = "/fusato/config/includes.bootstrap"
|
BOOTSTRAP = "/fusato/config/includes.bootstrap"
|
||||||
FUSATOCONFIG = "/fusato/config"
|
FUSATOCONFIG = "/fusato/config"
|
||||||
|
BASE_CONFIG = {
|
||||||
|
"debian": {
|
||||||
|
"scripts_dir": "/server/scripts/debian/",
|
||||||
|
},
|
||||||
|
"devuan": {
|
||||||
|
"scripts_dir": "/server/scripts/devuan/",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Set up the logging format
|
# Set up the logging format
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
@ -145,11 +154,6 @@ class ChrootInstallerFiles:
|
||||||
for base in bases:
|
for base in bases:
|
||||||
cls(base)
|
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:
|
class BinaryFolders:
|
||||||
"""
|
"""
|
||||||
|
@ -314,40 +318,45 @@ class ServerConfigFiles:
|
||||||
Class to handle copying server configuration files based on the sbase.
|
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.
|
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.sbase = sbase
|
||||||
|
self.sarch = sarch
|
||||||
|
self.build_base = build_base
|
||||||
self.copy_server_config_files()
|
self.copy_server_config_files()
|
||||||
|
|
||||||
def copy_server_config_files(self):
|
def copy_server_config_files(self):
|
||||||
"""
|
"""
|
||||||
Copy server configuration files based on the sbase.
|
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:
|
if self.sbase not in BASE_CONFIG:
|
||||||
logger.error(f"Unsupported base: {self.sbase}")
|
logger.error(f"Unsupported base: {self.sbase}")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"Copy Server Configuration Files for {self.sbase.capitalize()}")
|
|
||||||
|
|
||||||
src_paths = [
|
src_paths = [
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'welcome.sh'),
|
'welcome.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_apache2.sh'),
|
'configure_apache2.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_firewalld.sh'),
|
'configure_firewalld.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_hostname.sh'),
|
'configure_hostname.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_mariadb.sh'),
|
'configure_mariadb.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_nginx.sh'),
|
'configure_nginx.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_php_and_docker.sh'),
|
'configure_php_and_docker.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_postfix.sh'),
|
'configure_postfix.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_postgresql.sh'),
|
'configure_postgresql.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_sqlite.sh'),
|
'configure_sqlite.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_ssh.sh'),
|
'configure_ssh.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'configure_static_ip.sh'),
|
'configure_static_ip.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'create_user.sh'),
|
'create_user.sh',
|
||||||
os.path.join(BASE_CONFIG[self.sbase]["scripts_dir"], 'update_and_install.sh'),
|
'update_and_install.sh',
|
||||||
]
|
]
|
||||||
|
|
||||||
des_paths = [
|
des_paths = [
|
||||||
|
@ -367,23 +376,26 @@ class ServerConfigFiles:
|
||||||
'/usr/local/bin',
|
'/usr/local/bin',
|
||||||
]
|
]
|
||||||
|
|
||||||
src_q = collections.deque(src_paths)
|
for src_file, des_dir in zip(src_paths, des_paths):
|
||||||
des_q = collections.deque(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)
|
||||||
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}")
|
logger.info(f"Copying {src_path} to {des_path}")
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error copying {src_path} to {des_path}: {e}")
|
logger.error(f"Error copying {src_path} to {des_path}: {e}")
|
||||||
else:
|
else:
|
||||||
logger.info(f"Successfully copied {src_path} to {des_path}")
|
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:
|
class ArchitectureFiles:
|
||||||
"""
|
"""
|
||||||
Copy all the needed files and folders to CHROOT. Depending on the
|
Copy all the needed files and folders to CHROOT. Depending on the
|
||||||
|
|
Loading…
Reference in New Issue