Skip to content

Commit

Permalink
Merge pull request #23 from GluuFederation/setup-4.5-mono
Browse files Browse the repository at this point in the history
fix(setup): adjust for monorepo
  • Loading branch information
yurem authored Nov 20, 2024
2 parents 3c9f970 + b62423e commit 5d75551
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 110 deletions.
13 changes: 13 additions & 0 deletions community-edition-setup/app_info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"JETTY_VERSION": "10.0.18",
"AMAZON_CORRETTO_VERSION": "11.0.24.8.1",
"OX_GITVERISON": "-SNAPSHOT",
"NODE_VERSION": "v16.16.0",
"OX_VERSION": "4.5.6",
"PASSPORT_VERSION": "4.5",
"JYTHON_VERSION": "2.7.3",
"OPENDJ_VERSION": "4.5.3",
"TWILIO_VERSION": "7.17.0",
"JSMPP_VERSION": "2.3.7",
"APPS_GIT_BRANCH": "4.5"
}
184 changes: 81 additions & 103 deletions community-edition-setup/gluu_install.py

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions community-edition-setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Config:
jetty_home = '/opt/jetty'
jetty_base = os.path.join(gluuOptFolder, 'jetty')
installed_instance = False
maven_root = 'https://jenkins.gluu.org'
maven_root = 'https://maven.gluu.org'
profile = SetupProfiles.CE

@classmethod
Expand All @@ -49,8 +49,6 @@ def determine_version(self):
self.currentGluuVersion = re.search('([\d.]+)', oxauth_info['version']).group().strip('.')
self.githubBranchName = oxauth_info['branch']

self.ce_setup_zip = 'https://github.com/GluuFederation/community-edition-setup/archive/%s.zip' % self.githubBranchName

@classmethod
def dump(self, dumpFile=False):
if not os.environ.get('gdebug'):
Expand Down
4 changes: 3 additions & 1 deletion community-edition-setup/setup_app/installers/casa.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def install(self):

#Adding twilio jar path to oxauth.xml
oxauth_xml_fn = os.path.join(self.jetty_base, 'oxauth/webapps/oxauth.xml')

extra_classpath_list = [
'./custom/libs/{}'.format(os.path.basename(twillo_package)),
'./custom/libs/{}'.format(os.path.basename(jsmpp_package)),
Expand All @@ -84,6 +84,8 @@ def copy_static(self):
for script_fn in glob.glob(os.path.join(Config.staticFolder, 'casa/scripts/*.*')):
self.run(['cp', script_fn, self.pylib_folder])

base.extract_file(base.current_app.gluu_zip, 'casa/extras/casa.pub', '/etc/certs')

def render_import_templates(self, import_script=True):

Config.templateRenderingDict['oxd_protocol'] = 'https'
Expand Down
2 changes: 1 addition & 1 deletion community-edition-setup/setup_app/installers/oxauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
self.register_progess()

self.source_files = [
(os.path.join(Config.distGluuFolder, 'oxauth.war'), Config.maven_root + '/maven/org/gluu/oxauth-server/%s/oxauth-server-%s.war' % (Config.oxVersion, Config.oxVersion)),
(os.path.join(Config.distGluuFolder, 'oxauth.war'), Config.maven_root + '/maven4/org/gluu/oxauth-server/%s/oxauth-server-%s.war' % (Config.oxVersion, Config.oxVersion)),
]

self.templates_folder = os.path.join(Config.templateFolder, self.service_name)
Expand Down
16 changes: 15 additions & 1 deletion community-edition-setup/setup_app/installers/oxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

class OxdInstaller(SetupUtils, BaseInstaller):




def __init__(self):
setattr(base.current_app, self.__class__.__name__, self)
self.service_name = 'oxd-server'
Expand All @@ -24,6 +27,11 @@ def __init__(self):
self.install_var = 'installOxd'
self.register_progess()

self.source_files = [
(os.path.join(Config.distGluuFolder, 'oxd-server.zip'), os.path.join(Config.maven_root, 'maven4/org/gluu/oxd-server/{0}{1}/oxd-server-{0}{1}-distribution.zip'.format(base.current_app.app_info['OX_VERSION'], base.current_app.app_info['OX_GITVERISON']))),
(os.path.join(Config.distGluuFolder, 'oxd-server-fips.zip'), os.path.join(Config.maven_root, 'maven4/org/gluu/oxd-server/{0}{1}/oxd-server-{0}{1}-distribution-bc-fips.zip'.format(base.current_app.app_info['OX_VERSION'], base.current_app.app_info['OX_GITVERISON']))),
]

self.oxd_server_yml_fn = os.path.join(self.oxd_root, 'conf/oxd-server.yml')
self.oxd_server_keystore_fn = os.path.join(self.oxd_root, 'conf/oxd-server.{}'.format(Config.default_store_type))
self.oxd_jwks_keystore_fn = os.path.join(self.oxd_root, 'conf/oxd-jwks.{}'.format(Config.default_store_type))
Expand All @@ -40,7 +48,7 @@ def oxd_hostname(self):

def install(self):
self.logIt("Installing {}".format(self.service_name.title()), pbar=self.service_name)
self.run(['tar', '-zxf', Config.oxd_package, '--no-same-owner', '--strip-components=1', '-C', self.oxd_root])
self.extract_files()

oxd_user = 'oxd-server' if Config.profile == SetupProfiles.DISA_STIG else Config.jetty_user
Config.templateRenderingDict['service_user'] = oxd_user
Expand Down Expand Up @@ -98,6 +106,12 @@ def install(self):

self.enable()

def extract_files(self):
oxd_zip_fn = self.source_files[1][0] if Config.profile == SetupProfiles.DISA_STIG else self.source_files[0][0]
base.extract_subdir(oxd_zip_fn, '', self.oxd_root, par_dir='')
base.extract_file(base.current_app.gluu_zip, 'oxd/debian/oxd-server', os.path.join(self.oxd_root, 'bin'))
os.makedirs(os.path.join(self.oxd_root, 'data'))

def get_yaml_config(self):
yml_str = self.readFile(self.oxd_server_yml_fn)
oxd_yaml = ruamel.yaml.load(yml_str, ruamel.yaml.RoundTripLoader)
Expand Down
69 changes: 68 additions & 1 deletion community-edition-setup/setup_app/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def get_os_description():
disk_st = os.statvfs('/')
current_free_disk_space = round(disk_st.f_bavail * disk_st.f_frsize / (1024 * 1024 *1024), 1)


def check_resources():

if current_file_max < static.file_max:
Expand Down Expand Up @@ -323,3 +322,71 @@ def check_port_available(port_list, host='localhost'):
socket_object.close()

return open_ports

def extract_file(zip_file, source, target, ren=False):
fn = None
zip_obj = zipfile.ZipFile(zip_file, "r")

for member in zip_obj.infolist():
if not member.is_dir() and member.filename.endswith(source):
if ren:
target_p = Path(target)
else:
p = Path(member.filename)
target_p = Path(target).joinpath(p.name)
if not target_p.parent.exists():
target_p.parent.mkdir(parents=True)
logIt(f"Extracting {source} from {zip_file} to {target}")
target_p.write_bytes(zip_obj.read(member))
fn = target_p.as_posix()
break

zip_obj.close()

return fn


def extract_subdir(zip_fn, sub_dir, target_dir, par_dir=None, overwrite=False):
target_fp = os.path.join(target_dir, os.path.basename(sub_dir))

logIt(f"Extracting {zip_fn} to {target_dir}")

zip_obj = zipfile.ZipFile(zip_fn, "r")
members = zip_obj.infolist()

if par_dir is None:
par_dir = members[0].filename

subdir_with_parent = os.path.join(par_dir, sub_dir) if par_dir else sub_dir

for member in members:
if member.filename.startswith(subdir_with_parent):
if sub_dir:
n = sub_dir.count('/') + 1
member_path = Path(member.filename)
extract_path = Path(*member_path.parts[n:]).as_posix()
else:
extract_path = member.filename

extracted_path = os.path.join(target_dir, extract_path)
if not overwrite and os.path.exists(extracted_path):
logIt(f"Overwrite disabled, not extracting {member.filename}")
continue

if member.is_dir():
if not os.path.exists(extracted_path):
logIt(f"Creating directory {extracted_path}")
os.makedirs(extracted_path)
else:
member.filename = extract_path
logIt(f"Extracting {member.filename} to {target_dir}")
zip_obj.extract(member, target_dir)

if member.external_attr > 0xffff:
os.chmod(extracted_path, member.external_attr >> 16)

zip_obj.close()

app_info_fn = os.environ.get('GLUU_APP_INFO') or os.path.join(par_dir, 'app_info.json')
current_app.app_info = readJsonFile(app_info_fn)
current_app.gluu_zip = os.path.join(Config.distFolder, f'gluu/gluu-{current_app.app_info["APPS_GIT_BRANCH"]}.zip')

0 comments on commit 5d75551

Please sign in to comment.