Skip to content

Commit

Permalink
feat: linux-setup node installer
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Jan 29, 2022
1 parent e445053 commit 662a27f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jans-linux-setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,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/jre', '/opt/node*', '/opt/jetty*', '/opt/jython*']
if argsp.profile == 'jans':
remove_list.append('/opt/opendj')
if not argsp.keep_downloads:
Expand Down
1 change: 1 addition & 0 deletions jans-linux-setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Config:
ldapBaseFolder = '/opt/opendj'
network = '/etc/sysconfig/network'
jetty_home = '/opt/jetty'
node_home = '/opt/node'
jetty_base = os.path.join(jansOptFolder, 'jetty')
installed_instance = False
profile = 'jans'
Expand Down
70 changes: 70 additions & 0 deletions jans-linux-setup/setup_app/installers/node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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):

"""This installer provides node installtion for Jans server."""

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

def __init__(self):
"""Inits NodeInstaller instance."""
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 Exception as e:
self.logIt("Error encountered while extracting archive {}: {}".format(nodeArchive, e))

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])


def installed(self):
if os.path.islink(Config.node_home):
node_target = os.readlink(Config.node_home)
if not node_target.startswith('/'):
node_target = os.path.join('/opt', node_target)
if os.path.exists(node_target):
return True

0 comments on commit 662a27f

Please sign in to comment.