Skip to content

Commit

Permalink
feat: jans-linux-setup debian 11 packages (#1769)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
devrimyatar authored Jul 12, 2022
1 parent 29910d5 commit 6fbef91
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 78 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 @@ -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')
Expand Down
5 changes: 5 additions & 0 deletions jans-linux-setup/jans_setup/setup_app/data/package_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions jans-linux-setup/jans_setup/setup_app/installers/jetty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
37 changes: 5 additions & 32 deletions jans-linux-setup/jans_setup/setup_app/installers/opendj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 0 additions & 42 deletions jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6fbef91

Please sign in to comment.