Skip to content

Commit

Permalink
feat(jans-linux-setup): Retreive Agama Lab project scripts (#10335)
Browse files Browse the repository at this point in the history
* feat(jans-linux-setup): retreive agam lab project scripts

Signed-off-by: Mustafa Baser <mbaser@mail.com>

* chore(jans-linux-setup): remove empty file

Signed-off-by: Mustafa Baser <mbaser@mail.com>

---------

Signed-off-by: Mustafa Baser <mbaser@mail.com>
  • Loading branch information
devrimyatar authored Dec 4, 2024
1 parent 570060c commit 26713a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions jans-linux-setup/jans_setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def progress(self, service_name, msg, incr=False):
os.path.join(self.install_dir, 'static/scripts/testBind.py'),
os.path.join(self.install_dir, 'static/scripts/jans'),
os.path.join(self.install_dir, 'static/scripts/jans_services_status.py'),
os.path.join(self.install_dir, 'static/scripts/get_agama_lab_projects.py'),
]

self.redhat_services = ['httpd', 'rsyslog']
Expand Down
12 changes: 7 additions & 5 deletions jans-linux-setup/jans_setup/setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,12 @@ def copy_scripts(self):
self.copyFile(script, Config.jansOptBinFolder)
self.run([paths.cmd_chmod, '+x', script])


health_services_script_fn = os.path.join(Config.jansOptBinFolder, os.path.basename(Config.jansScriptFiles[3]))
self.chown(health_services_script_fn, user=Config.root_user, group=Config.jetty_user)
self.run([paths.cmd_chmod, '0750', health_services_script_fn])
# scripts that can be executed by user jetty
jetty_user_scripts = (Config.jansScriptFiles[3], Config.jansScriptFiles[4])
for script in jetty_user_scripts:
script_fn = os.path.join(Config.jansOptBinFolder, os.path.basename(script))
self.chown(script_fn, user=Config.root_user, group=Config.jetty_user)
self.run([paths.cmd_chmod, '0750', script_fn])

self.logIt("Rendering encode.py")
encode_script = self.readFile(os.path.join(Config.templateFolder, 'encode.py'))
Expand Down Expand Up @@ -308,7 +310,7 @@ def copy_scripts(self):
else:
scr_content.insert(0, first_line)
self.writeFile(scr_path, '\n'.join(scr_content), backup=False)
if scr.name in (show_version_s, os.path.basename(health_services_script_fn)):
if scr.name in [show_version_s] + [os.path.basename(_) for _ in jetty_user_scripts]:
continue
self.run([paths.cmd_chmod, '700', scr_path])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /usr/bin/env python3

import requests
import json

def get_projects():

try:
response = requests.get('https://github.com/orgs/GluuFederation/repositories?q=agama-', headers={"Accept":"application/json"})
result = response.json()
downloads = []
for repo in result["payload"]["repositories"]:
repo_name = repo["name"]
response = requests.get(f'https://api.github.com/repos/GluuFederation/{repo_name}/releases/latest', headers={'Accept': 'application/json'})
if response.ok:
result = response.json()
for asset in result['assets']:
if asset['name'].endswith('.gama'):
downloads.append({'repository-name': repo_name, 'description': repo['description'], 'download-link': asset['browser_download_url']})
return {'result': True, 'projects': downloads, 'error': None}
except Exception as e:
return {'result': True, 'projects': [], 'error': str(e)}

if __name__ == '__main__':
result = get_projects()
print(json.dumps(result, indent=2))

0 comments on commit 26713a8

Please sign in to comment.