update python modules for the server builds
This commit is contained in:
parent
617a81c439
commit
3df65a2aca
|
@ -95,7 +95,6 @@ def set_fusato_server_installer_structure():
|
||||||
# Define the directories to be created in includes-installer
|
# Define the directories to be created in includes-installer
|
||||||
installer_dirs = ['/preseed',
|
installer_dirs = ['/preseed',
|
||||||
'/usr/lib/finish-install.d/',
|
'/usr/lib/finish-install.d/',
|
||||||
'/usr/share/'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Create the directories in includes-installer
|
# Create the directories in includes-installer
|
||||||
|
|
|
@ -24,14 +24,6 @@ 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 = {
|
|
||||||
"debsrv": {
|
|
||||||
"scripts_dir": "/server/scripts/debian/",
|
|
||||||
},
|
|
||||||
"devsrv": {
|
|
||||||
"scripts_dir": "/server/scripts/devuan/",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the logging format
|
# Set up the logging format
|
||||||
|
@ -314,75 +306,95 @@ def mini_shared_installer_files():
|
||||||
logger.info(f"Copy completed: {des_path}")
|
logger.info(f"Copy completed: {des_path}")
|
||||||
|
|
||||||
class ServerConfigFiles:
|
class ServerConfigFiles:
|
||||||
|
"""
|
||||||
|
Copies server initial config files CHROOT depending on the base.
|
||||||
"""
|
"""
|
||||||
Class to handle copying server configuration files.
|
ALLOWED_BASES = {"debsrv", "devsrv"}
|
||||||
"""
|
def __init__(self, base, sarch=None):
|
||||||
|
self.base = base
|
||||||
def __init__(self,sbase,sarch):
|
|
||||||
logger.info("Copy server configuration files")
|
|
||||||
self.sbase = sbase
|
|
||||||
self.sarch = sarch
|
self.sarch = sarch
|
||||||
|
if self.base not in self.ALLOWED_BASES:
|
||||||
|
logger.warning(f"Base '{self.base}' is not allowed. Skipping.")
|
||||||
|
return
|
||||||
|
logger.info(f"Copy Server Files for base: {self.base}")
|
||||||
|
server_path = '/server/scripts/'
|
||||||
|
self.src_paths = (
|
||||||
|
f'{server_path}{self.base}/welcome.sh',
|
||||||
|
f'{server_path}{self.base}/configure_apache2.sh',
|
||||||
|
f'{server_path}{self.base}/configure_firewalld.sh',
|
||||||
|
f'{server_path}{self.base}/configure_hostname.sh',
|
||||||
|
f'{server_path}{self.base}/configure_mariadb.sh',
|
||||||
|
f'{server_path}{self.base}/configure_nginx.sh',
|
||||||
|
f'{server_path}{self.base}/configure_php_and_docker.sh',
|
||||||
|
f'{server_path}{self.base}/configure_postfix.sh',
|
||||||
|
f'{server_path}{self.base}/configure_postgresql.sh',
|
||||||
|
f'{server_path}{self.base}/configure_sqlite.sh',
|
||||||
|
f'{server_path}{self.base}/configure_ssh.sh',
|
||||||
|
f'{server_path}{self.base}/configure_static_ip.sh',
|
||||||
|
f'{server_path}{self.base}/create_user.sh',
|
||||||
|
f'{server_path}{self.base}/update_and_install.sh'
|
||||||
|
)
|
||||||
|
|
||||||
def copy_server_config_files(self):
|
self.des_paths = (
|
||||||
"""
|
'/usr/local/bin',
|
||||||
Copy server configuration files .
|
'/usr/local/bin',
|
||||||
"""
|
'/usr/local/bin',
|
||||||
logger.info(f"Copying server configuration files for {self.sbase.capitalize()}")
|
'/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'
|
||||||
|
)
|
||||||
|
self.copy_files()
|
||||||
|
|
||||||
src_paths = [
|
|
||||||
'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 = [
|
def copy_files(self):
|
||||||
'/usr/local/bin',
|
""" Ensure destination directories exist before copying"""
|
||||||
'/usr/local/bin',
|
for des in self.des_paths:
|
||||||
'/usr/local/bin',
|
full_des_path = os.path.join(HOME_FOLDER, WPCHROOT.strip('/'), des.strip('/'))
|
||||||
'/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',
|
|
||||||
]
|
|
||||||
|
|
||||||
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:
|
try:
|
||||||
if os.path.isdir(src_path):
|
os.makedirs(full_des_path, exist_ok=True)
|
||||||
shutil.copytree(src_path, des_path, ignore_dangling_symlinks=True)
|
logger.info(f"Ensured directory exists: {full_des_path}")
|
||||||
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 creating directory {full_des_path}: {e}")
|
||||||
else:
|
src_q = collections.deque(self.src_paths)
|
||||||
logger.info(f"Successfully copied {src_path} to {des_path}")
|
des_q = collections.deque(self.des_paths)
|
||||||
|
size_q = len(src_q)
|
||||||
# Exemplo de uso:
|
for _ in range(size_q):
|
||||||
if __name__ == "__main__":
|
source = src_q.popleft()
|
||||||
sbase = build_base.sbase
|
des = des_q.popleft()
|
||||||
sarch = build_base.sarch
|
full_src_path = os.path.join(HOME_FOLDER, source.strip('/'))
|
||||||
server_config_files = ServerConfigFiles(sbase, sarch, build_base)
|
full_des_path = os.path.join(HOME_FOLDER,
|
||||||
|
WPCHROOT.strip('/'), des.strip('/')
|
||||||
|
)
|
||||||
|
logger.info(MSG_COPY + full_src_path)
|
||||||
|
try:
|
||||||
|
if os.path.exists(full_src_path):
|
||||||
|
if os.path.isdir(full_src_path):
|
||||||
|
shutil.copytree(full_src_path,
|
||||||
|
os.path.join(full_des_path,
|
||||||
|
os.path.basename(full_src_path)),
|
||||||
|
dirs_exist_ok=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
shutil.copy(full_src_path, full_des_path)
|
||||||
|
logger.info(MSG_FIN + full_des_path)
|
||||||
|
else:
|
||||||
|
logger.error(f"Source path does not exist: {full_src_path}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error copying {full_src_path} to {full_des_path}: {e}")
|
||||||
|
@classmethod
|
||||||
|
def run_for_all_bases(cls):
|
||||||
|
""" Define the bases to be used"""
|
||||||
|
bases = ["debsrv", "devsrv", "invalid_base"]
|
||||||
|
for base in bases:
|
||||||
|
cls(base)
|
||||||
|
|
||||||
class ArchitectureFiles:
|
class ArchitectureFiles:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue