diff --git a/jans-linux-setup/jans_setup/install.py b/jans-linux-setup/jans_setup/install.py index 7292fdd95a3..4106665db14 100755 --- a/jans-linux-setup/jans_setup/install.py +++ b/jans-linux-setup/jans_setup/install.py @@ -12,7 +12,6 @@ import json import tempfile -from types import SimpleNamespace from urllib import request from urllib.parse import urljoin, urlparse from pathlib import Path @@ -22,10 +21,11 @@ SETUP_BRANCH = 'main' -app_globals.package_dependencies = [] - +package_dependencies = [] +jans_dir = '/opt/jans' jans_app_dir = '/opt/dist/jans' maven_base_url = 'https://maven.jans.io/maven/io/jans/' +jetty_home = '/opt/jans/jetty' jans_zip_file = os.path.join(jans_app_dir, 'jans.zip') package_installer = shutil.which('apt') or shutil.which('dnf') or shutil.which('yum') or shutil.which('zypper') @@ -42,92 +42,40 @@ parser.add_argument('-yes', help="No prompt", action='store_true') parser.add_argument('--keep-downloads', help="Keep downloaded files (applicable for uninstallation only)", action='store_true') parser.add_argument('--profile', help="Setup profile", choices=['jans', 'openbanking'], default='jans') -parser.add_argument('--no-setup', help="Do not launch setup", action='store_true') -parser.add_argument('--no-jans-setup', help="Do not extract jans-setup", action='store_true') -parser.add_argument('--no-gcs', help="Do not download gcs", action='store_true') -parser.add_argument('-setup-dir', help="Setup directory", default=os.path.join(jans_dir, 'jans-setup')) -parser.add_argument('--force-download', help="Force downloading files", action='store_true') +parser.add_argument('-download-exit', help="Downloads files and exits", action='store_true') +parser.add_argument('--setup-branch', help="Jannsen setup github branch", default="main") +parser.add_argument('--setup-dir', help="Setup directory", default=os.path.join(jans_dir, 'jans-setup')) +parser.add_argument('-force-download', help="Force downloading files", action='store_true') +argsp = parser.parse_args() def check_install_dependencies(): try: from distutils import dist except: - app_globals.package_dependencies.append('python3-distutils') + package_dependencies.append('python3-distutils') try: import ldap3 except: - app_globals.package_dependencies.append('python3-ldap3') + package_dependencies.append('python3-ldap3') - if app_globals.package_dependencies and not app_globals.argsp.yes: - install_dist = input('Required package(s): {}. Install now? [Y/n] '.format(', '.join(app_globals.package_dependencies))) + if package_dependencies and not argsp.yes: + install_dist = input('Required package(s): {}. Install now? [Y/n] '.format(', '.join(package_dependencies))) if install_dist.lower().startswith('n'): print("Can't continue...") sys.exit() - os.system('{} install -y {}'.format(package_installer, ' '.join(app_globals.package_dependencies))) - - -def extract_subdir(zip_fn, sub_dir, target_dir, zipf=None): - zip_obj = zipfile.ZipFile(zip_fn, "r") - par_dir = zip_obj.namelist()[0] - - if not sub_dir.endswith('/'): - sub_dir += '/' - - if zipf: - target_zip_obj = zipfile.ZipFile(zipf, "w") + os.system('{} install -y {}'.format(package_installer, ' '.join(package_dependencies))) - ssub_dir = os.path.join(par_dir, sub_dir) - target_dir_path = Path(target_dir) - - if target_dir_path.exists(): - shutil.rmtree(target_dir_path) - - target_dir_path.mkdir(parents=True) - - for member in zip_obj.infolist(): - if member.filename.startswith(ssub_dir): - p = Path(member.filename) - pr = p.relative_to(ssub_dir) - target_fn = target_dir_path.joinpath(pr) - if member.is_dir(): - if zipf: - z_dirn = target_fn.as_posix() - if not z_dirn.endswith('/'): - z_dirn += '/' - zinfodir = zipfile.ZipInfo(filename=z_dirn) - zinfodir.external_attr=0x16 - target_zip_obj.writestr(zinfodir, '') - elif not target_fn.exists(): - target_fn.mkdir(parents=True) - else: - if zipf: - target_zip_obj.writestr(target_fn.as_posix(), zip_obj.read(member)) - else: - if not target_fn.parent.exists(): - target_fn.parent.mkdir(parents=True) - target_fn.write_bytes(zip_obj.read(member)) - if zipf: - target_zip_obj.close() - zip_obj.close() +def download_jans_acrhieve(): + jans_acrhieve_url = 'https://github.com/JanssenProject/jans/archive/refs/heads/{}.zip'.format(argsp.setup_branch) + print("Downloading {} as {}".format(jans_acrhieve_url, jans_zip_file)) + request.urlretrieve(jans_acrhieve_url, jans_zip_file) -def download(url, target_fn): - dst = target_fn if target_fn.startswith('/') else os.path.join(app_dir, target_fn) - pardir, fn = os.path.split(dst) - if not os.path.exists(pardir): - os.makedirs(pardir) - print("Downloading", url, "to", dst) - request.urlretrieve(url, dst) - - -setup_url = 'https://github.com/JanssenProject/jans/archive/refs/heads/{}.zip'.format(app_globals.app_versions['SETUP_BRANCH']) -download(setup_url, jans_zip_file) - def check_installation(): if not (os.path.exists(jetty_home) and os.path.exists('/etc/jans/conf/jans.properties')): @@ -136,8 +84,8 @@ def check_installation(): def profile_setup(): - print("Preparing Setup for profile {}".format(app_globals.argsp.profile)) - profile_dir = os.path.join(app_globals.argsp.setup_dir, app_globals.argsp.profile) + print("Preparing Setup for profile {}".format(argsp.profile)) + profile_dir = os.path.join(argsp.setup_dir, argsp.profile) replace_dirs = [] if not os.path.exists(profile_dir): print("Profile directory {} does not exist. Exiting ...".format(profile_dir)) @@ -154,11 +102,11 @@ def profile_setup(): replaced_dirs = [] for pdir in replace_dirs: source_dir = os.path.join(profile_dir, pdir) - target_dir = os.path.join(app_globals.argsp.setup_dir, pdir) + target_dir = os.path.join(argsp.setup_dir, pdir) replaced_dirs.append(source_dir) if os.path.exists(source_dir) and os.path.exists(target_dir): shutil.rmtree(target_dir) - copy_target = os.path.join(app_globals.argsp.setup_dir, os.path.sep.join(os.path.split(pdir)[:-1])) + copy_target = os.path.join(argsp.setup_dir, os.path.sep.join(os.path.split(pdir)[:-1])) print(target_dir) shutil.copytree(source_dir, target_dir) @@ -166,7 +114,7 @@ def profile_setup(): if root.startswith(tuple(replaced_dirs)): continue if files: - target_dir = Path(app_globals.argsp.setup_dir).joinpath(Path(root).relative_to(Path(profile_dir))) + target_dir = Path(argsp.setup_dir).joinpath(Path(root).relative_to(Path(profile_dir))) for f in files: if f in ['.profiledirs']: continue @@ -175,24 +123,36 @@ def profile_setup(): shutil.copy(source_file, target_dir) def extract_setup(): - if os.path.exists(app_globals.argsp.setup_dir): - shutil.move(app_globals.argsp.setup_dir, app_globals.argsp.setup_dir + '-back.' + time.ctime()) + if os.path.exists(argsp.setup_dir): + shutil.move(argsp.setup_dir, argsp.setup_dir + '-back.' + time.ctime()) + print("Extracting jans-setup package") - extract_subdir(jans_zip_file, 'jans-linux-setup/jans_setup', app_globals.argsp.setup_dir) + jans_zip = zipfile.ZipFile(jans_zip_file) + parent_dir = jans_zip.filelist[0].orig_filename + + with tempfile.TemporaryDirectory() as tmp_dir: + jans_zip.extractall(tmp_dir) + shutil.copytree(os.path.join(tmp_dir, parent_dir, 'jans-linux-setup/jans_setup'), argsp.setup_dir) - target_setup = os.path.join(app_globals.argsp.setup_dir, 'setup.py') + jans_zip.close() + + target_setup = os.path.join(argsp.setup_dir, 'setup.py') if not os.path.exists(target_setup): - os.symlink(os.path.join(app_globals.argsp.setup_dir, 'jans_setup.py'), target_setup) + os.symlink(os.path.join(argsp.setup_dir, 'jans_setup.py'), target_setup) o = urlparse(maven_base_url) - app_globals.app_versions['JANS_MAVEN'] = o._replace(path='').geturl() - app_info_fn = os.path.join(app_globals.argsp.setup_dir, 'app_info.json') + app_info_fn = os.path.join(argsp.setup_dir, 'app_info.json') + with open(app_info_fn) as f: + app_info = json.load(f) + + app_info['JANS_MAVEN'] = o._replace(path='').geturl() + with open(app_info_fn, 'w') as w: - json.dump(app_globals.app_versions, w, indent=2) + json.dump(app_info, w, indent=2) def uninstall_jans(): check_installation() - if not app_globals.argsp.yes: + if not argsp.yes: print('\033[31m') print("This process is irreversible.") print("You will lose all data related to Janssen Server.") @@ -211,7 +171,7 @@ def uninstall_jans(): print("Please type \033[1m yes \033[0m to uninstall") print("Uninstalling Jannsen Server...") - for service in app_globals.jetty_services: + for service in os.listdir(jetty_home): if os.path.exists(os.path.join(jetty_home, service)): default_fn = os.path.join('/etc/default/', service) if os.path.exists(default_fn): @@ -220,14 +180,14 @@ def uninstall_jans(): print("Stopping", service) os.system('systemctl stop ' + service) - if app_globals.argsp.profile == 'jans': + if argsp.profile == 'jans': print("Stopping OpenDj Server") os.system('/opt/opendj/bin/stop-ds') remove_list = ['/etc/certs', '/etc/jans', '/opt/jans', '/opt/amazon-corretto*', '/opt/jre', '/opt/node*', '/opt/jetty*', '/opt/jython*'] - if app_globals.argsp.profile == 'jans': + if argsp.profile == 'jans': remove_list.append('/opt/opendj') - if not app_globals.argsp.keep_downloads: + if not argsp.keep_downloads: remove_list.append('/opt/dist') for p in remove_list: @@ -239,7 +199,7 @@ def uninstall_jans(): def upgrade(): check_installation() - for service in app_globals.jetty_services: + for service in os.listdir(jetty_home): source_fn = os.path.join('/opt/dist/jans', service +'.war') target_fn = os.path.join(jetty_home, service, 'webapps', service +'.war' ) if os.path.exists(target_fn): @@ -259,39 +219,43 @@ def upgrade(): os.system('systemctl restart jans-config-api') def do_install(): - if not app_globals.argsp.no_jans_setup: - extract_setup() - if app_globals.argsp.profile != 'jans': + extract_setup() + + if argsp.profile != 'jans': profile_setup() - if not app_globals.argsp.no_setup: - print("Launching Janssen Setup") - setup_cmd = 'python3 {}/setup.py'.format(app_globals.argsp.setup_dir) + print("Launching Janssen Setup") - if app_globals.argsp.args: - setup_cmd += ' ' + app_globals.argsp.args + setup_cmd = 'python3 {}/setup.py'.format(argsp.setup_dir) + setup_args = argsp.args or '' + if argsp.force_download: + setup_args += ' --force-download' - os.system(setup_cmd) + if argsp.use_downloaded: + setup_args += ' --use-downloaded' + if argsp.download_exit: + setup_args += ' --download-exit' -def download_files(): - pass + if argsp.args: + setup_cmd += ' ' + argsp.args + print("Executing", setup_cmd) + os.system(setup_cmd) def main(): - app_globals.argsp = parser.parse_known_args()[0] - if not app_globals.argsp.uninstall: + if not argsp.uninstall: check_install_dependencies() - if not (app_globals.argsp.use_downloaded or app_globals.argsp.uninstall): - download_files() + if not (argsp.use_downloaded or argsp.uninstall): + download_jans_acrhieve() - if app_globals.argsp.upgrade: + if argsp.upgrade: upgrade() - elif app_globals.argsp.uninstall: + elif argsp.uninstall: uninstall_jans() else: do_install() diff --git a/jans-linux-setup/jans_setup/jans_setup.py b/jans-linux-setup/jans_setup/jans_setup.py index a1a676dda72..c191b48147b 100755 --- a/jans-linux-setup/jans_setup/jans_setup.py +++ b/jans-linux-setup/jans_setup/jans_setup.py @@ -82,6 +82,10 @@ def ami_packaged(): sys.path.insert(0, os.path.join(base.pylib_dir, 'gcs')) +if argsp.download_exit: + downloads.download_all() + sys.exit() + from setup_app.utils.package_utils import packageUtils packageUtils.check_and_install_packages() diff --git a/jans-linux-setup/jans_setup/setup_app/config.py b/jans-linux-setup/jans_setup/setup_app/config.py index 9a737118fc5..8f94628b980 100644 --- a/jans-linux-setup/jans_setup/setup_app/config.py +++ b/jans-linux-setup/jans_setup/setup_app/config.py @@ -31,6 +31,9 @@ class Config: node_home = '/opt/node' outputFolder = None jetty_base = os.path.join(jansOptFolder, 'jetty') + distAppFolder = os.path.join(distFolder, 'app') + distJansFolder = os.path.join(distFolder, 'jans') + installed_instance = False profile = 'jans' diff --git a/jans-linux-setup/jans_setup/setup_app/downloads.py b/jans-linux-setup/jans_setup/setup_app/downloads.py index 634c07bf0e8..c7701aa8023 100644 --- a/jans-linux-setup/jans_setup/setup_app/downloads.py +++ b/jans-linux-setup/jans_setup/setup_app/downloads.py @@ -1,14 +1,16 @@ import os import sys +import glob import shutil -import tempfile import zipfile +import tempfile +import importlib.util from setup_app.utils import base def download_jans_acrhieve(): - if base.argsp.use_downloaded and os.path.exists(base.current_app.jans_zip): + if not base.argsp.force_download and os.path.exists(base.current_app.jans_zip): return base.download( @@ -70,6 +72,28 @@ def download_sqlalchemy(): base.download(base.current_app.app_info['SQLALCHEMY'], sqlalchemy_zip_file, verbose=True) base.extract_subdir(sqlalchemy_zip_file, 'lib/sqlalchemy', sqlalchemy_dir) + +def download_all(): + download_files = [] + + modules = glob.glob(os.path.join(base.ces_dir, 'installers/*.py')) + + for installer in modules: + if installer.startswith('__') or not os.path.isfile(installer): + continue + spec = importlib.util.spec_from_file_location('module.name', installer) + foo = importlib.util.module_from_spec(spec) + spec.loader.exec_module(foo) + + for m in dir(foo): + module = getattr(foo, m) + if hasattr(module, 'source_files'): + download_files += module.source_files + + for path, url in download_files: + base.download(url, path, verbose=True) + + def download_apps(): download_jans_acrhieve() if base.Config.profile == 'jans': diff --git a/jans-linux-setup/jans_setup/setup_app/installers/base.py b/jans-linux-setup/jans_setup/setup_app/installers/base.py index 986dca37021..b3de2b8cd9d 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/base.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/base.py @@ -191,22 +191,9 @@ def download_files(self, force=False, downloads=[]): if downloads and not src_name in downloads: continue - if force or self.check_download_needed(src): + if force or not os.path.exists(src): self.download_file(url, src) - def check_download_needed(self, src): - if not os.path.exists(src): - return True - - froot, fext = os.path.splitext(src) - if fext in ('.war', '.jar'): - if os.path.exists(src): - war_info = get_war_info(src) - if war_info.get('version'): - return LooseVersion(war_info['version']) < LooseVersion(base.current_app.app_info['ox_version']) - - return True - def create_user(self): pass diff --git a/jans-linux-setup/jans_setup/setup_app/installers/config_api.py b/jans-linux-setup/jans_setup/setup_app/installers/config_api.py index 36873d03d37..75119060b18 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/config_api.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/config_api.py @@ -17,6 +17,14 @@ class ConfigApiInstaller(JettyInstaller): + source_files = [ + (os.path.join(Config.distJansFolder, 'jans-config-api.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api-server/{0}/jans-config-api-server-{0}.war').format(base.current_app.app_info['ox_version'])), + (os.path.join(Config.distJansFolder, 'scim-plugin.jar'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/scim-plugin/{0}/scim-plugin-{0}-distribution.jar').format(base.current_app.app_info['ox_version'])), + (os.path.join(Config.distJansFolder, 'facter'), 'https://raw.githubusercontent.com/GluuFederation/gluu-snap/master/facter/facter'), + #(os.path.join(Config.data_dir, 'jans-config-api-swagger.yaml'), 'https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/docs/jans-config-api-swagger.yaml'), + (os.path.join(Config.distJansFolder, 'user-mgt-plugin.jar'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/user-mgt-plugin/{0}/user-mgt-plugin-{0}-distribution.jar').format(base.current_app.app_info['ox_version'])), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jans-config-api' @@ -39,19 +47,9 @@ def __init__(self): self.libDir = os.path.join(self.jetty_base, self.service_name, 'custom/libs/') self.custom_config_dir = os.path.join(self.jetty_base, self.service_name, 'custom/config') - self.source_files = [ - (os.path.join(Config.distJansFolder, 'jans-config-api.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api-server/{0}/jans-config-api-server-{0}.war').format(base.current_app.app_info['ox_version'])), - (os.path.join(Config.distJansFolder, 'scim-plugin.jar'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/scim-plugin/{0}/scim-plugin-{0}-distribution.jar').format(base.current_app.app_info['ox_version'])), - (os.path.join(Config.distJansFolder, 'facter'), 'https://raw.githubusercontent.com/GluuFederation/gluu-snap/master/facter/facter'), - (os.path.join(Config.data_dir, 'jans-config-api-swagger.yaml'), 'https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/docs/jans-config-api-swagger.yaml'), - (os.path.join(Config.distJansFolder, 'user-mgt-plugin.jar'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/user-mgt-plugin/{0}/user-mgt-plugin-{0}-distribution.jar').format(base.current_app.app_info['ox_version'])), - ] - self.extract_files() def install(self): - if not os.path.exists(self.source_files[3][0]): - base.download(self.source_files[3][1], self.source_files[3][0]) self.copyFile(self.source_files[2][0], '/usr/sbin') self.run([paths.cmd_chmod, '+x', '/usr/sbin/facter']) @@ -62,8 +60,8 @@ def install(self): self.copyFile(self.source_files[1][0], self.libDir) scim_plugin_path = os.path.join(self.libDir, os.path.basename(self.source_files[1][0])) self.add_extra_class(scim_plugin_path) - self.copyFile(self.source_files[4][0], self.libDir) - user_mgt_plugin_path = os.path.join(self.libDir, os.path.basename(self.source_files[4][0])) + self.copyFile(self.source_files[3][0], self.libDir) + user_mgt_plugin_path = os.path.join(self.libDir, os.path.basename(self.source_files[3][0])) self.add_extra_class(user_mgt_plugin_path) self.enable() diff --git a/jans-linux-setup/jans_setup/setup_app/installers/eleven.py b/jans-linux-setup/jans_setup/setup_app/installers/eleven.py index 0187909f3bb..9718a3a5a5a 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/eleven.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/eleven.py @@ -12,6 +12,10 @@ class ElevenInstaller(JettyInstaller): + source_files = [ + (os.path.join(Config.distJansFolder, 'jans-eleven.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-eleven-server/{0}/jans-eleven-server-{0}.war').format(base.current_app.app_info['ox_version'])) + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jans-eleven' @@ -21,9 +25,6 @@ def __init__(self): self.install_var = 'installEleven' self.register_progess() - self.source_files = [ - (os.path.join(Config.distJansFolder, 'jans-eleven.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-eleven-server/{0}/jans-eleven-server-{0}.war').format(base.current_app.app_info['ox_version'])) - ] self.output_folder = os.path.join(Config.outputFolder, 'jans-eleven') self.template_folder = os.path.join(Config.templateFolder, 'jans-eleven') diff --git a/jans-linux-setup/jans_setup/setup_app/installers/fido.py b/jans-linux-setup/jans_setup/setup_app/installers/fido.py index dac5dcb7fd2..6cac94cc4ff 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/fido.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/fido.py @@ -10,6 +10,11 @@ class FidoInstaller(JettyInstaller): + source_files = [ + (os.path.join(Config.distJansFolder, 'jans-fido2.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-fido2-server/{0}/jans-fido2-server-{0}.war').format(base.current_app.app_info['ox_version'])), + (os.path.join(Config.distAppFolder, os.path.basename(base.current_app.app_info['APPLE_WEBAUTHN'])), base.current_app.app_info['APPLE_WEBAUTHN']) + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jans-fido2' @@ -19,11 +24,6 @@ def __init__(self): self.install_var = 'installFido2' self.register_progess() - self.source_files = [ - (os.path.join(Config.distJansFolder, 'jans-fido2.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-fido2-server/{0}/jans-fido2-server-{0}.war').format(base.current_app.app_info['ox_version'])), - (os.path.join(Config.distAppFolder, os.path.basename(base.current_app.app_info['APPLE_WEBAUTHN'])), base.current_app.app_info['APPLE_WEBAUTHN']) - ] - self.fido2ConfigFolder = os.path.join(Config.configFolder, 'fido2') self.output_folder = os.path.join(Config.outputFolder, 'jans-fido2') self.template_folder = os.path.join(Config.templateFolder, 'jans-fido2') diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jans_cli.py b/jans-linux-setup/jans_setup/setup_app/installers/jans_cli.py index 29a1e83f640..ba4299946b9 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jans_cli.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jans_cli.py @@ -17,6 +17,12 @@ class JansCliInstaller(BaseInstaller, SetupUtils): + source_files = [ + (os.path.join(Config.distJansFolder, 'jca-swagger-client.zip'), os.path.join(base.current_app.app_info['EXTERNAL_LIBS'], 'cli-swagger/jca_swagger_client.zip')), + (os.path.join(Config.distJansFolder, 'scim-swagger-client.zip'), os.path.join(base.current_app.app_info['EXTERNAL_LIBS'], 'cli-swagger/scim_swagger_client.zip')), + (os.path.join(Config.distAppFolder, 'pyjwt.zip'), base.current_app.app_info['PYJWT']), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jans-cli' @@ -37,11 +43,6 @@ def __init__(self): if not base.snap: self.register_progess() - self.source_files = [ - (os.path.join(Config.distJansFolder, 'jca-swagger-client.zip'), os.path.join(base.current_app.app_info['EXTERNAL_LIBS'], 'cli-swagger/jca_swagger_client.zip')), - (os.path.join(Config.distJansFolder, 'scim-swagger-client.zip'), os.path.join(base.current_app.app_info['EXTERNAL_LIBS'], 'cli-swagger/scim_swagger_client.zip')), - (os.path.join(Config.distAppFolder, 'pyjwt.zip'), base.current_app.app_info['PYJWT']), - ] def install(self): diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jetty.py b/jans-linux-setup/jans_setup/setup_app/installers/jetty.py index 85d9e09f62c..eeb81956386 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jetty.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jetty.py @@ -18,6 +18,11 @@ class JettyInstaller(BaseInstaller, SetupUtils): jetty_base = Config.jetty_base jetty_app_configuration = base.readJsonFile(os.path.join(paths.DATA_DIR, 'jetty_app_configuration.json'), ordered=True) + jetty_link = 'https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/{0}/jetty-home-{0}.tar.gz'.format(base.current_app.app_info['JETTY_VERSION']) + source_files = [ + (os.path.join(Config.distAppFolder, os.path.basename(jetty_link)), jetty_link), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jetty' @@ -56,10 +61,6 @@ def __init__(self): } } - jetty_link = 'https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/{0}/jetty-home-{0}.tar.gz'.format(base.current_app.app_info['JETTY_VERSION']) - self.source_files = [ - (os.path.join(Config.distAppFolder, os.path.basename(jetty_link)), jetty_link), - ] def install(self): diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jre.py b/jans-linux-setup/jans_setup/setup_app/installers/jre.py index 31bdb7830c8..e43a7ebf129 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jre.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jre.py @@ -14,6 +14,11 @@ class JreInstaller(BaseInstaller, SetupUtils): + amazon_corretto_link = 'https://corretto.aws/downloads/resources/{0}/amazon-corretto-{0}-linux-x64.tar.gz'.format(base.current_app.app_info['AMAZON_CORRETTO_VERSION']) + source_files = [ + (os.path.join(Config.distAppFolder, os.path.basename(amazon_corretto_link)), amazon_corretto_link), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jre' @@ -24,23 +29,23 @@ def __init__(self): if not base.snap: self.register_progess() - self.open_jdk_archive_link = 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9.1_1.tar.gz' - self.amazon_corretto_link = 'https://corretto.aws/downloads/resources/{0}/amazon-corretto-{0}-linux-x64.tar.gz'.format(base.current_app.app_info['AMAZON_CORRETTO_VERSION']) - - def install(self): - # we need to call download_files() unless it called by base installer - if not Config.downloadWars: - self.download_files() + if Config.java_type == 'jdk': + open_jdk_archive_link = 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9.1_1.tar.gz' + target_fn = os.path.join(Config.distAppFolder, os.path.basename(open_jdk_archive_link)) + base.download(open_jdk_archive_link, target_fn) + jreArchive = target_fn + else: + jreArchive = self.source_files[0][0] - self.logIt("Installing server JRE {} ...".format(os.path.basename(self.jreArchive))) + self.logIt("Installing server JRE {} ...".format(os.path.basename(jreArchive))) try: - self.logIt("Extracting %s into /opt/" % os.path.basename(self.jreArchive)) - self.run([paths.cmd_tar, '-xzf', self.jreArchive, '-C', '/opt/', '--no-xattrs', '--no-same-owner', '--no-same-permissions']) + self.logIt("Extracting %s into /opt/" % os.path.basename(jreArchive)) + self.run([paths.cmd_tar, '-xzf', jreArchive, '-C', '/opt/', '--no-xattrs', '--no-same-owner', '--no-same-permissions']) except Exception as e: - self.logIt("Error encountered while extracting archive %s" % self.jreArchive) + self.logIt("Error encountered while extracting archive {}".format(e)) if Config.java_type == 'jdk': jreDestinationPath = max(glob.glob('/opt/jdk-11*')) @@ -62,14 +67,6 @@ def install(self): self.fix_java_security() - def download_files(self, force=False, downloads=[]): - download_link = self.open_jdk_archive_link if Config.java_type == 'jdk' else self.amazon_corretto_link - jre_fn = os.path.basename(download_link) - self.jreArchive = os.path.join(Config.distAppFolder, jre_fn) - if not os.path.exists(self.jreArchive) or force and not (downloads and src_name not in downloads): - self.logIt("Downloading " + jre_fn, pbar=self.service_name) - base.download(download_link, self.jreArchive) - def fix_java_security(self): # https://github.com/OpenIdentityPlatform/OpenDJ/issues/78 java_security_fn = os.path.join(Config.jre_home, 'conf/security/java.security') diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jython.py b/jans-linux-setup/jans_setup/setup_app/installers/jython.py index b4bca6ce5ec..151ecfd2b0a 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jython.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jython.py @@ -11,6 +11,11 @@ class JythonInstaller(BaseInstaller, SetupUtils): + jython_link = 'https://maven.gluu.org/maven/org/gluufederation/jython-installer/{0}/jython-installer-{0}.jar'.format(base.current_app.app_info['JYTHON_VERSION']) + source_files = [ + (os.path.join(Config.distAppFolder, os.path.basename(jython_link)), jython_link), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jython' @@ -22,11 +27,6 @@ def __init__(self): self.needdb = False # we don't need backend connection in this class - jython_link = 'https://maven.gluu.org/maven/org/gluufederation/jython-installer/{0}/jython-installer-{0}.jar'.format(base.current_app.app_info['JYTHON_VERSION']) - self.source_files = [ - (os.path.join(Config.distAppFolder, os.path.basename(jython_link)), jython_link), - ] - def install(self): diff --git a/jans-linux-setup/jans_setup/setup_app/installers/opendj.py b/jans-linux-setup/jans_setup/setup_app/installers/opendj.py index ab3bed69fc1..76a9173f07a 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/opendj.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/opendj.py @@ -16,6 +16,11 @@ class OpenDjInstaller(BaseInstaller, SetupUtils): + opendj_link = 'https://maven.gluu.org/maven/org/gluufederation/opendj/opendj-server-legacy/{0}/opendj-server-legacy-{0}.zip'.format(base.current_app.app_info['OPENDJ_VERSION']) + source_files = [ + (os.path.join(Config.distAppFolder, os.path.basename(opendj_link)), opendj_link), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'opendj' @@ -33,11 +38,6 @@ def __init__(self): self.ldapDsconfigCommand = os.path.join(Config.ldapBinFolder, 'dsconfig') self.ldapDsCreateRcCommand = os.path.join(Config.ldapBinFolder, 'create-rc-script') - opendj_link = 'https://maven.gluu.org/maven/org/gluufederation/opendj/opendj-server-legacy/{0}/opendj-server-legacy-{0}.zip'.format(base.current_app.app_info['OPENDJ_VERSION']) - self.source_files = [ - (os.path.join(Config.distAppFolder, os.path.basename(opendj_link)), opendj_link), - ] - def install(self): self.logIt("Running OpenDJ Setup") diff --git a/jans-linux-setup/jans_setup/setup_app/installers/scim.py b/jans-linux-setup/jans_setup/setup_app/installers/scim.py index f4280c63d37..2fb4bdb1b27 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/scim.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/scim.py @@ -11,6 +11,10 @@ class ScimInstaller(JettyInstaller): + source_files = [ + (os.path.join(Config.distJansFolder, 'jans-scim.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-scim-server/{0}/jans-scim-server-{0}.war').format(base.current_app.app_info['ox_version'])), + ] + def __init__(self): setattr(base.current_app, self.__class__.__name__, self) self.service_name = 'jans-scim' @@ -20,10 +24,6 @@ def __init__(self): self.install_var = 'installScimServer' self.register_progess() - self.source_files = [ - (os.path.join(Config.distJansFolder, 'jans-scim.war'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-scim-server/{0}/jans-scim-server-{0}.war').format(base.current_app.app_info['ox_version'])), - ] - self.templates_folder = os.path.join(Config.templateFolder, self.service_name) self.output_folder = os.path.join(Config.outputFolder, self.service_name) diff --git a/jans-linux-setup/jans_setup/setup_app/utils/arg_parser.py b/jans-linux-setup/jans_setup/setup_app/utils/arg_parser.py index cd767f014f0..d1493958074 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/arg_parser.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/arg_parser.py @@ -85,13 +85,14 @@ parser.add_argument('-approved-issuer', help="Api Approved Issuer") -parser.add_argument('-use-downloaded', help="Use already downloaded components", action='store_true') parser.add_argument('--force-download', help="Force downloading files", action='store_true') +parser.add_argument('--download-exit', help="Download files and exits", action='store_true') parser.add_argument('-jans-app-version', help="Version for Jannses applications") parser.add_argument('-jans-build', help="Buid version for Janssen applications") parser.add_argument('-setup-branch', help="Jannsen setup github branch", default='main') + def add_to_me(you): base.logIt("Adding actions from parser: '{}'".format(you.description)) diff --git a/jans-linux-setup/jans_setup/setup_app/utils/progress.py b/jans-linux-setup/jans_setup/setup_app/utils/progress.py index 99173e09cc6..5549373f7c3 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/progress.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/progress.py @@ -134,6 +134,6 @@ def progress(self, service_name, msg='', incr=False): if self.queue: self.queue.put({'current': service_name, 'msg': msg}) elif service_name != static.COMPLETED: - print("Process {}:{}".format(service_name, msg)) + print("Process {}: {}".format(service_name, msg)) jansProgress = JansProgress()