Skip to content

Commit

Permalink
fix(jans-linux-setup): replace jetty favicon (#8334)
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Baser <mbaser@mail.com>
  • Loading branch information
devrimyatar committed Apr 18, 2024
1 parent 9f8c120 commit 5baa87f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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.

0 comments on commit 5baa87f

Please sign in to comment.