Skip to content

Commit

Permalink
fix: jans-linux-setup start mysql server before jans-auth on SUSE (#3500
Browse files Browse the repository at this point in the history
)
  • Loading branch information
devrimyatar authored Jan 3, 2023
1 parent b64917c commit 3822975
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions jans-linux-setup/jans_setup/setup_app/installers/rdbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ def reset_rdbm_db(self):
self.dbUtils.session.commit()
self.dbUtils.metadata.clear()

def fix_unit_file(self, service_name):
unit_fn_ = self.run(['systemctl', 'show', '-P', 'FragmentPath', service_name])
if unit_fn_ and unit_fn_.strip():
unit_fn = unit_fn_.strip()
if os.path.exists(unit_fn):
unit_file_content = self.readFile(unit_fn.strip())
unit_file_content_list = unit_file_content.splitlines()
unit_content = False

for i, l in enumerate(unit_file_content_list[:]):
if l.strip().lower() == '[unit]':
unit_content = True
if not l.strip() and unit_content:
unit_file_content_list.insert(i, 'Before=jans-auth.service')
break

unit_file_content_list.append('')
self.writeFile(unit_fn, '\n'.join(unit_file_content_list))
self.run(['systemctl', 'daemon-reload'])

def local_install(self):
if not Config.rdbm_password:
Config.rdbm_password = self.getPW()
Expand All @@ -78,7 +98,9 @@ def local_install(self):
if Config.rdbm_type == 'mysql':
if base.os_type == 'suse':
self.restart('mariadb')
self.fix_unit_file('mariadb')
self.enable('mariadb')

elif base.clone_type == 'rpm':
self.restart('mysqld')
self.enable('mysqld')
Expand Down

0 comments on commit 3822975

Please sign in to comment.