Skip to content

Commit

Permalink
feat(flex-linux-setup): change admin-ui log location to /var/log/adminui
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Oct 25, 2023
1 parent c817b55 commit 9d1d3e0
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions flex-linux-setup/flex_linux_setup/flex_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pathlib import Path
from urllib import request
from urllib.parse import urljoin
from xml.etree import ElementTree


argsp = None
Expand Down Expand Up @@ -281,7 +282,7 @@ def __init__(self):

self.jans_auth_dir = os.path.join(Config.jetty_base, jansAuthInstaller.service_name)
self.jans_auth_custom_lib_dir = os.path.join(self.jans_auth_dir, 'custom/libs')

self.admin_ui_log_dir = '/var/log/adminui'
self.gluu_admin_ui_source_path = os.path.join(Config.dist_jans_dir, 'gluu-admin-ui.zip')
self.log4j2_adminui_path = os.path.join(Config.dist_jans_dir, 'log4j2-adminui.xml')
self.log4j2_path = os.path.join(Config.dist_jans_dir, 'log4j2.xml')
Expand Down Expand Up @@ -526,8 +527,32 @@ def install_config_api_plugin(self):
config_api_installer.copyFile(self.admin_ui_plugin_source_path, config_api_installer.libDir, backup=False)
config_api_installer.add_extra_class(self.admin_ui_plugin_path)

for logfn in (self.log4j2_adminui_path, self.log4j2_path):
config_api_installer.copyFile(logfn, config_api_installer.custom_config_dir)
config_api_installer.copyFile(self.log4j2_path, config_api_installer.custom_config_dir)

log4j2_adminui_path_target_path = os.path.join(
config_api_installer.custom_config_dir,
os.path.basename(self.log4j2_adminui_path)
)

print("Reading XML", self.log4j2_adminui_path)
tree = ElementTree.parse(self.log4j2_adminui_path)
root = tree.getroot()

for appenders in root.findall('Appenders'):
for child in appenders:
if child.tag=='RollingFile' and child.get('name') in ('ADMINUI-AUDIT', 'ADMINUI-LOG'):
for prop in ('fileName', 'filePattern'):
file_name = child.get(prop)
if file_name:
file_base_name = os.path.basename(file_name)
new_file_path = os.path.join(self.admin_ui_log_dir, file_base_name)
child.set(prop, new_file_path)
print("Writing XML", log4j2_adminui_path_target_path)
tree.write(log4j2_adminui_path_target_path, encoding='utf-8', xml_declaration=True)

if not os.path.exists(self.admin_ui_log_dir):
os.makedirs(self.admin_ui_log_dir)
config_api_installer.chown(self.admin_ui_log_dir, Config.jetty_user, Config.jetty_group)

config_api_installer.set_class_path(glob.glob(os.path.join(config_api_installer.libDir, '*.jar')))

Expand Down

0 comments on commit 9d1d3e0

Please sign in to comment.