Skip to content

fix(jans-linux-setup): replace jetty favicon #8334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/jetty.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def install(self):

self.applyChangesInFiles(self.app_custom_changes[NAME_STR])

self.replace_favicon()

self.chown(jettyDestinationPath, Config.jetty_user, Config.jetty_group, recursive=True)
self.run([paths.cmd_chown, '-h', '{}:{}'.format(Config.jetty_user, Config.jetty_group), self.jetty_home])

Expand All @@ -98,6 +100,23 @@ def install(self):
self.chown(self.jetty_bin_sh_fn, Config.jetty_user, Config.jetty_group, recursive=True)
self.run([paths.cmd_chmod, '-R', '755', self.jetty_bin_sh_fn])

def replace_favicon(self):
# icon directory
icon_subdir = 'org/eclipse/jetty'
favicon_fn = 'favicon.ico'
icon_dir = os.path.join(self.jetty_user_home_lib, icon_subdir)
self.createDirs(icon_dir)

# extract favicon
base.extract_file(base.current_app.jans_zip, f'jans-linux-setup/jans_setup/static/{favicon_fn}', os.path.join(icon_dir, favicon_fn), ren=True)

_, jetty_dist = self.get_jetty_info()
jetty_server_fn = f'{jetty_dist}/{self.jetty_dist_string}-{self.jetty_exact_version_string}/lib/jetty-server-{self.jetty_exact_version_string}.jar'

# replace favicon
self.run([Config.cmd_jar, '-uf', jetty_server_fn, os.path.join(icon_subdir, favicon_fn)], cwd=self.jetty_user_home_lib)


def get_jetty_info(self):
# first try latest versions
self.jetty_dist_string = 'jetty-home'
Expand All @@ -109,13 +128,15 @@ def get_jetty_info(self):
jetty_archive = max(jetty_archive_list)

jetty_archive_fn = os.path.basename(jetty_archive)
jetty_regex = re.search('{}-(\d*\.\d*)'.format(self.jetty_dist_string), jetty_archive_fn)
jetty_regex = re.search(f'{self.jetty_dist_string}-(\d*\.\d*)', jetty_archive_fn)
jetty_exact_version_regex = re.search(f'{self.jetty_dist_string}-(\d*\.\d*.\d*)', jetty_archive_fn)
if not jetty_regex:
self.logIt("Can't determine Jetty version", True, True)

jetty_dist = '/opt/jetty-' + jetty_regex.groups()[0]
Config.templateRenderingDict['jetty_dist'] = jetty_dist
self.jetty_version_string = jetty_regex.groups()[0]
self.jetty_exact_version_string = jetty_exact_version_regex.groups()[0]

return jetty_archive, jetty_dist

Expand Down
Binary file added jans-linux-setup/jans_setup/static/favicon.ico
Binary file not shown.