Skip to content

Commit

Permalink
feat: add node installer
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Dec 31, 2021
1 parent d96afbd commit 07c1a67
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
5 changes: 4 additions & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"JYTHON_VERSION": "2.7.3",
"OPENDJ_VERSION": "4.4.12",
"SETUP_BRANCH": "master",
"ADMIN_UI_FRONTEND_BRANCH": "master",
"NODE_VERSION": "v14.16.1"
}

jans_dir = '/opt/jans'
Expand Down Expand Up @@ -143,6 +145,7 @@ def download_gcs():
download('https://corretto.aws/downloads/resources/{0}/amazon-corretto-{0}-linux-x64.tar.gz'.format(app_versions['AMAZON_CORRETTO_VERSION']), os.path.join(app_dir, 'amazon-corretto-{0}-linux-x64.tar.gz'.format(app_versions['AMAZON_CORRETTO_VERSION'])))
download('https://repo1.maven.org/maven2/org/eclipse/jetty/{1}/{0}/{1}-{0}.tar.gz'.format(app_versions['JETTY_VERSION'], jetty_dist_string), os.path.join(app_dir,'{1}-{0}.tar.gz'.format(app_versions['JETTY_VERSION'], jetty_dist_string)))
download('https://maven.gluu.org/maven/org/gluufederation/jython-installer/{0}/jython-installer-{0}.jar'.format(app_versions['JYTHON_VERSION']), os.path.join(app_dir, 'jython-installer-{0}.jar'.format(app_versions['JYTHON_VERSION'])))
download('https://nodejs.org/dist/{0}/node-{0}-linux-x64.tar.xz'.format(app_versions['NODE_VERSION']), os.path.join(app_dir, 'node-{0}-linux-x64.tar.xz'.format(app_versions['NODE_VERSION'])))
download(urljoin(maven_base_url, 'jans-auth-server/{0}{1}/jans-auth-server-{0}{1}.war'.format(app_versions['JANS_APP_VERSION'], app_versions['JANS_BUILD'])), os.path.join(jans_app_dir, 'jans-auth.war'))
download(urljoin(maven_base_url, 'jans-auth-client/{0}{1}/jans-auth-client-{0}{1}-jar-with-dependencies.jar'.format(app_versions['JANS_APP_VERSION'], app_versions['JANS_BUILD'])), os.path.join(jans_app_dir, 'jans-auth-client-jar-with-dependencies.jar'))
download(urljoin(maven_base_url, 'jans-config-api-server/{0}{1}/jans-config-api-server-{0}{1}.war'.format(app_versions['JANS_APP_VERSION'], app_versions['JANS_BUILD'])), os.path.join(jans_app_dir, 'jans-config-api.war'))
Expand Down Expand Up @@ -270,7 +273,7 @@ def profile_setup():
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/jetty*', '/opt/jython*']
remove_list = ['/etc/certs', '/etc/jans', '/opt/jans', '/opt/amazon-corretto*', '/opt/node*', '/opt/jre', '/opt/jetty*', '/opt/jython*']
if argsp.profile == 'jans':
remove_list.append('/opt/opendj')
if not argsp.keep_downloads:
Expand Down
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from setup_app.installers.jre import JreInstaller
from setup_app.installers.jetty import JettyInstaller
from setup_app.installers.jython import JythonInstaller
from setup_app.installers.node import NodeInstaller
from setup_app.installers.jans_auth import JansAuthInstaller

if Config.profile == 'jans':
Expand All @@ -67,8 +68,6 @@
from setup_app.installers.config_api import ConfigApiInstaller
from setup_app.installers.jans_cli import JansCliInstaller
from setup_app.installers.rdbm import RDBMInstaller


# from setup_app.installers.oxd import OxdInstaller

if base.snap:
Expand Down Expand Up @@ -157,17 +156,22 @@
jreInstaller = JreInstaller()
jettyInstaller = JettyInstaller()
jythonInstaller = JythonInstaller()
nodeInstaller = NodeInstaller()

if Config.profile == 'jans':
openDjInstaller = OpenDjInstaller()
couchbaseInstaller = CouchbaseInstaller()

rdbmInstaller = RDBMInstaller()
httpdinstaller = HttpdInstaller()
jansAuthInstaller = JansAuthInstaller()
configApiInstaller = ConfigApiInstaller()

if Config.profile == 'jans':
fidoInstaller = FidoInstaller()
scimInstaller = ScimInstaller()
elevenInstaller = ElevenInstaller()

jansCliInstaller = JansCliInstaller()

# oxdInstaller = OxdInstaller()
Expand Down Expand Up @@ -266,6 +270,8 @@ def do_installation():
jreInstaller.start_installation()
jettyInstaller.start_installation()
jythonInstaller.start_installation()
if Config.installAdminUI:
nodeInstaller.start_installation()

jansInstaller.copy_scripts()
jansInstaller.encode_passwords()
Expand Down
1 change: 1 addition & 0 deletions setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __repr__(self):


txt += 'Install Apache 2 web server'.ljust(30) + repr(Config.installHttpd).rjust(35) + (' *' if 'installHttpd' in Config.addPostSetupService else '') + "\n"
txt += 'Install Node'.ljust(30) + repr(Config.installAdminUI).rjust(35) + "\n"
txt += 'Install Auth Server'.ljust(30) + repr(Config.installOxAuth).rjust(35) + "\n"
txt += 'Install Jans Auth Config Api'.ljust(30) + repr(Config.installConfigApi).rjust(35) + "\n"
txt += 'Install Jans Admin UI'.ljust(30) + repr(Config.installAdminUI).rjust(35) + "\n"
Expand Down
58 changes: 58 additions & 0 deletions setup_app/installers/node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import os
import glob

from setup_app import paths
from setup_app.utils import base
from setup_app.static import AppType, InstallOption
from setup_app.config import Config
from setup_app.utils.setup_utils import SetupUtils
from setup_app.installers.base import BaseInstaller

class NodeInstaller(BaseInstaller, SetupUtils):

node_base = os.path.join(Config.jansOptFolder, 'node')
templates_rendered = False

def __init__(self):
self.service_name = 'node'
self.needdb = False # we don't need backend connection in this class
self.install_var = 'installNode'
self.app_type = AppType.APPLICATION
self.install_type = InstallOption.MONDATORY
if not base.snap:
self.register_progess()

self.node_user_home = '/home/node'

def install(self):

node_archieve_list = glob.glob(os.path.join(Config.distAppFolder, 'node-*-linux-x64.tar.xz'))

if not node_archieve_list:
self.logIt("Can't find node archive", True, True)

if not base.snap:
self.createUser('node', self.node_user_home)
self.addUserToGroup('jans', 'node')

nodeArchive = max(node_archieve_list)

try:
self.logIt("Extracting %s into /opt" % nodeArchive)
self.run([paths.cmd_tar, '-xJf', nodeArchive, '-C', '/opt/', '--no-xattrs', '--no-same-owner', '--no-same-permissions'])
except:
self.logIt("Error encountered while extracting archive %s" % nodeArchive)

nodeDestinationPath = max(glob.glob('/opt/node-*-linux-x64'))

self.run([paths.cmd_ln, '-sf', nodeDestinationPath, Config.node_home])
self.run([paths.cmd_chmod, '-R', "755", "%s/bin/" % nodeDestinationPath])

# Create temp folder
self.run([paths.cmd_mkdir, '-p', "%s/temp" % Config.node_home])

self.run([paths.cmd_chown, '-R', 'node:node', nodeDestinationPath])
self.run([paths.cmd_chown, '-h', 'node:node', Config.node_home])

self.run([paths.cmd_mkdir, '-p', self.node_base])
self.run([paths.cmd_chown, '-R', 'node:node', self.node_base])

0 comments on commit 07c1a67

Please sign in to comment.