update infra script
This commit is contained in:
parent
92e0bdeec8
commit
dc57dcd238
|
@ -620,58 +620,60 @@ def shared_server_files():
|
||||||
)
|
)
|
||||||
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
|
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):
|
def server_config_files(sbase):
|
||||||
"""
|
"""
|
||||||
This function copies specific files used for server builds
|
This function copies specific server build files adapted for the provided base (sbase).
|
||||||
and configures them based on the provided base (sbase).
|
|
||||||
"""
|
"""
|
||||||
base_config = {
|
logger = logging.getLogger(__name__)
|
||||||
"debian": {
|
|
||||||
"scripts_dir": "/server/scripts/debian/",
|
|
||||||
},
|
|
||||||
"devuan": {
|
|
||||||
"scripts_dir": "/server/scripts/devuan/",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sbase not in base_config:
|
if sbase not in BASE_CONFIG:
|
||||||
logger.error(f"Unsupported base: {sbase}")
|
logger.error(f"Unsupported base: {sbase}")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"Copy Shared Files for {sbase.capitalize()}")
|
logger.info(f"Copy Shared Files for {sbase.capitalize()}")
|
||||||
|
|
||||||
src_paths = [
|
src_paths = [
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'welcome.sh'),
|
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_apache2.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'configure_firewalld.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_hostname.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'configure_mariadb.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_nginx.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'configure_php_and_docker.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_postfix.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'configure_postgresql.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_sqlite.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'configure_ssh.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"], 'configure_static_ip.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'create_user.sh'),
|
os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'create_user.sh'),
|
||||||
os.path.join(base_config[sbase]["scripts_dir"], 'update_and_install.sh'),
|
os.path.join(BASE_CONFIG[sbase]["scripts_dir"], 'update_and_install.sh'),
|
||||||
]
|
]
|
||||||
|
|
||||||
des_paths = [
|
des_paths = [
|
||||||
'/usr/local/bin/welcome.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_apache2.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_firewalld.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_hostname.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_mariadb.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_nginx.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_php_and_docker.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_postfix.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_postgresql.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_sqlite.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_ssh.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/configure_static_ip.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/create_user.sh',
|
'/usr/local/bin',
|
||||||
'/usr/local/bin/update_and_install.sh',
|
'/usr/local/bin',
|
||||||
]
|
]
|
||||||
|
|
||||||
src_q = collections.deque(src_paths)
|
src_q = collections.deque(src_paths)
|
||||||
|
@ -680,8 +682,8 @@ def server_config_files(sbase):
|
||||||
while src_q and des_q:
|
while src_q and des_q:
|
||||||
src = src_q.popleft()
|
src = src_q.popleft()
|
||||||
des = des_q.popleft()
|
des = des_q.popleft()
|
||||||
src_path = os.path.join(HOME_FOLDER, src)
|
src_path = os.path.join(os.environ['HOME'], src)
|
||||||
des_path = os.path.join(HOME_FOLDER, des)
|
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:
|
||||||
|
@ -691,15 +693,6 @@ def server_config_files(sbase):
|
||||||
else:
|
else:
|
||||||
logger.info(f"Successfully copied {src_path} to {des_path}")
|
logger.info(f"Successfully copied {src_path} to {des_path}")
|
||||||
|
|
||||||
logger.info(f"Configuring server for {sbase.capitalize()}")
|
|
||||||
|
|
||||||
if sbase == "debian":
|
|
||||||
# Add Debian specific configuration logic here
|
|
||||||
pass
|
|
||||||
elif sbase == "devuan":
|
|
||||||
# Add Devuan specific configuration logic here
|
|
||||||
pass
|
|
||||||
|
|
||||||
def boostrap_shared():
|
def boostrap_shared():
|
||||||
"""
|
"""
|
||||||
Copy specific folders in the boostrap location
|
Copy specific folders in the boostrap location
|
||||||
|
|
Loading…
Reference in New Issue