From 6fbef91dcb4e14aaa78a898d945ef2c2e38ca722 Mon Sep 17 00:00:00 2001 From: Devrim Date: Tue, 12 Jul 2022 19:49:35 +0300 Subject: [PATCH] feat: jans-linux-setup debian 11 packages (#1769) * feat: jans-linux-setup debian 11 packages * refactor: jans-linux-setup remove fix_init_scripts() * fix: jans-linux-setup opendj unit file * fix: jans-linux-setup add debian11 to deb_sysd_clone --- .../jans_setup/setup_app/config.py | 1 + .../setup_app/data/package_list.json | 5 +++ .../jans_setup/setup_app/installers/base.py | 2 +- .../jans_setup/setup_app/installers/jetty.py | 2 - .../jans_setup/setup_app/installers/opendj.py | 37 +++------------- .../jans_setup/setup_app/utils/base.py | 2 +- .../jans_setup/setup_app/utils/setup_utils.py | 42 ------------------- 7 files changed, 13 insertions(+), 78 deletions(-) diff --git a/jans-linux-setup/jans_setup/setup_app/config.py b/jans-linux-setup/jans_setup/setup_app/config.py index c96c7ba6266..faa14570693 100644 --- a/jans-linux-setup/jans_setup/setup_app/config.py +++ b/jans-linux-setup/jans_setup/setup_app/config.py @@ -31,6 +31,7 @@ class Config: network = '/etc/sysconfig/network' jetty_home = '/opt/jetty' node_home = '/opt/node' + unit_files_path = '/etc/systemd/system' output_dir = None jetty_base = os.path.join(jansOptFolder, 'jetty') dist_app_dir = os.path.join(distFolder, 'app') diff --git a/jans-linux-setup/jans_setup/setup_app/data/package_list.json b/jans-linux-setup/jans_setup/setup_app/data/package_list.json index 4ee90876c52..374c2f666b0 100644 --- a/jans-linux-setup/jans_setup/setup_app/data/package_list.json +++ b/jans-linux-setup/jans_setup/setup_app/data/package_list.json @@ -23,6 +23,11 @@ "optional": "", "mondatory": "apache2 apache2-mod_auth_openidc curl wget tar xz unzip rsyslog bzip2", "python": {"ldap3":"python3-ldap3", "requests":"python3-requests", "ruamel.yaml":"python3-ruamel.yaml", "certifi":"python3-certifi", "pymysql":"python3-PyMySQL", "Crypto": "python3-cryptography", "prompt_toolkit": "python3-prompt_toolkit"} + }, + "debian 11": { + "optional": "", + "mondatory": "apache2 curl wget tar xz-utils unzip rsyslog bzip2", + "python": {"ldap3":"python3-ldap3", "requests":"python3-requests", "ruamel.yaml":"python3-ruamel.yaml", "certifi":"python3-certifi", "pymysql":"python3-pymysql", "Crypto": "python3-cryptography", "distutils.util": "python3-distutils", "prompt_toolkit": "python3-prompt-toolkit"} }, "debian 10": { "optional": "", 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 b3de2b8cd9d..3d6b5edb626 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/base.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/base.py @@ -38,7 +38,7 @@ def start_installation(self): # copy unit file unit_file = os.path.join(Config.staticFolder, 'system/systemd', self.service_name + '.service') if os.path.exists(unit_file): - self.copyFile(unit_file, '/etc/systemd/system') + self.copyFile(unit_file, Config.unit_files_path) self.install() self.copy_static() 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 72449ba296b..4d976308981 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jetty.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jetty.py @@ -223,8 +223,6 @@ def installJettyService(self, serviceConfiguration, supportCustomizations=False, except: self.logIt("Error rendering service '%s' context xml" % service_name, True) - self.fix_init_scripts(service_name, self.jetty_bin_sh_fn) - if not base.snap: tmpfiles_base = '/usr/lib/tmpfiles.d' if Config.os_initdaemon == 'systemd' and os.path.exists(tmpfiles_base): 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 66103d7905c..2746adb066c 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/opendj.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/opendj.py @@ -35,7 +35,7 @@ def __init__(self): self.openDjIndexJson = os.path.join(Config.install_dir, 'static/opendj/index.json') self.openDjSchemaFolder = os.path.join(Config.ldap_base_dir, 'config/schema') - self.opendj_service_centos7 = os.path.join(Config.install_dir, 'static/opendj/systemd/opendj.service') + self.unit_file = os.path.join(Config.install_dir, 'static/opendj/systemd/opendj.service') self.ldapDsconfigCommand = os.path.join(Config.ldap_bin_dir , 'dsconfig') self.ldapDsCreateRcCommand = os.path.join(Config.ldap_bin_dir , 'create-rc-script') @@ -345,38 +345,11 @@ def prepare_opendj_schema(self): def setup_opendj_service(self): if not base.snap: + self.copyFile(self.unit_file, Config.unit_files_path) init_script_fn = '/etc/init.d/opendj' - if (base.clone_type == 'rpm' and base.os_initdaemon == 'systemd') or base.deb_sysd_clone: - remove_init_script = True - opendj_script_name = os.path.basename(self.opendj_service_centos7) - opendj_dest_folder = "/etc/systemd/system" - try: - self.copyFile(self.opendj_service_centos7, opendj_dest_folder) - except: - self.logIt("Error copying script file %s to %s" % (opendj_script_name, opendj_dest_folder)) - if os.path.exists(init_script_fn): - self.run(['rm', '-f', init_script_fn]) - else: - self.run([self.ldapDsCreateRcCommand, '--outputFile', '/etc/init.d/opendj', '--userName', Config.ldap_user]) - # Make the generated script LSB compliant - lsb_str=( - '### BEGIN INIT INFO\n' - '# Provides: opendj\n' - '# Required-Start: $remote_fs $syslog\n' - '# Required-Stop: $remote_fs $syslog\n' - '# Default-Start: 2 3 4 5\n' - '# Default-Stop: 0 1 6\n' - '# Short-Description: Start daemon at boot time\n' - '# Description: Enable service provided by daemon.\n' - '### END INIT INFO\n' - ) - self.insertLinesInFile("/etc/init.d/opendj", 1, lsb_str) - - if base.os_type in ['ubuntu', 'debian']: - self.run([paths.cmd_update_rc, "-f", "opendj", "remove"]) - - self.fix_init_scripts('opendj', init_script_fn) - + if os.path.exists(init_script_fn): + self.removeFile(init_script_fn) + self.run([self.ldapDsCreateRcCommand, '--outputFile', init_script_fn, '--userName', Config.ldap_user]) self.reload_daemon() diff --git a/jans-linux-setup/jans_setup/setup_app/utils/base.py b/jans-linux-setup/jans_setup/setup_app/utils/base.py index 139bc0f088b..f79ec640831 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/base.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/base.py @@ -72,7 +72,7 @@ sys.exit() os_name = os_type + os_version -deb_sysd_clone = os_name in ('ubuntu18', 'ubuntu20', 'ubuntu22', 'debian9', 'debian10') +deb_sysd_clone = os_name in ('ubuntu18', 'ubuntu20', 'ubuntu22', 'debian9', 'debian10', 'debian11') # Determine service path if (os_type in ('centos', 'red', 'fedora', 'suse') and os_initdaemon == 'systemd') or deb_sysd_clone: diff --git a/jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py b/jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py index 2588a23aecb..86c557062ed 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py @@ -446,48 +446,6 @@ def addUserToGroup(self, groupName, userName): except: self.logIt("Error adding group", True) - def fix_init_scripts(self, serviceName, initscript_fn): - if base.snap: - return - - changeTo = None - - couchbase_mappings = self.getMappingType('couchbase') - - if Config.persistence_type == 'couchbase' or 'default' in couchbase_mappings: - changeTo = 'couchbase-server' - - if Config.get('opendj_install') == InstallTypes.REMOTE or Config.get('cb_install') == InstallTypes.REMOTE: - changeTo = '' - - if serviceName in Config.service_requirements: - if changeTo != None: - for service in Config.service_requirements: - Config.service_requirements[service][0] = Config.service_requirements[service][0].replace('opendj', changeTo) - - with open(initscript_fn) as f: - initscript = f.readlines() - - for i,l in enumerate(initscript): - if l.startswith('# Provides:'): - initscript[i] = '# Provides: {0}\n'.format(serviceName) - elif l.startswith('# description:'): - initscript[i] = '# description: Jetty 9 {0}\n'.format(serviceName) - elif l.startswith('# Required-Start:'): - initscript[i] = '# Required-Start: $local_fs $network {0}\n'.format(Config.service_requirements[serviceName][0]) - elif l.startswith('# chkconfig:'): - initscript[i] = '# chkconfig: 345 {0} {1}\n'.format(Config.service_requirements[serviceName][1], 100 - Config.service_requirements[serviceName][1]) - - if (base.clone_type == 'rpm' and base.os_initdaemon == 'systemd') or base.deb_sysd_clone: - service_init_script_fn = os.path.join(Config.distFolder, 'scripts', serviceName) - else: - service_init_script_fn = os.path.join('/etc/init.d', serviceName) - - with open(service_init_script_fn, 'w') as W: - W.write(''.join(initscript)) - - self.run([paths.cmd_chmod, '+x', service_init_script_fn]) - def load_certificate_text(self, filePath): self.logIt("Load certificate %s" % filePath) certificate_text = self.readFile(filePath)