Skip to content

Commit

Permalink
fix: suse fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Jan 25, 2022
1 parent b8b1ec6 commit e674315
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
14 changes: 8 additions & 6 deletions jans-ce-setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
parser.add_argument('--jans-app-version', help="Version for Jannses applications")
parser.add_argument('--jans-build', help="Buid version for Janssen applications")
parser.add_argument('--setup-branch', help="Jannsen setup github branch")
parser.add_argument('--no-setup', help="Do not launch setup", action='store_true')

if '-a' in sys.argv:
parser.add_argument('--jetty-version', help="Jetty verison. For example 11.0.6")
Expand Down Expand Up @@ -99,7 +100,7 @@
print("Can't continue...")
sys.exit()

os.system('{} install -y {}'.format(package_installer, ' '.join(package_dependencies)))
os.system('{} install -y {}'.format(package_installer, ' '.join(package_dependencies)))


def extract_subdir(zip_fn, sub_dir, target_dir, zipf=None):
Expand Down Expand Up @@ -382,11 +383,12 @@ def profile_setup():
print("Preparing jans-cli package")
extract_subdir(jans_zip_file, 'jans-cli', 'jans-cli', os.path.join(jans_app_dir, 'jans-cli.zip'))

print("Launching Janssen Setup")
if not argsp.no_setup:
print("Launching Janssen Setup")

setup_cmd = 'python3 {}/setup.py'.format(setup_dir)
setup_cmd = 'python3 {}/setup.py'.format(setup_dir)

if argsp.args:
setup_cmd += ' ' + argsp.args
if argsp.args:
setup_cmd += ' ' + argsp.args

os.system(setup_cmd)
os.system(setup_cmd)
14 changes: 7 additions & 7 deletions jans-ce-setup/setup_app/installers/httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def __init__(self):
self.apache2_ssl_24_conf = os.path.join(self.output_folder, 'https_jans.conf')

if base.os_type == 'suse':
self.https_gluu_fn = '/etc/apache2/vhosts.d/_https_gluu.conf'
self.https_jans_fn = '/etc/apache2/vhosts.d/_https_gluu.conf'
elif base.clone_type == 'rpm':
self.https_gluu_fn = '/etc/httpd/conf.d/https_gluu.conf'
self.https_jans_fn = '/etc/httpd/conf.d/https_gluu.conf'
else:
self.https_gluu_fn = '/etc/apache2/sites-available/https_gluu.conf'
self.https_jans_fn = '/etc/apache2/sites-available/https_gluu.conf'


def configure(self):
Expand Down Expand Up @@ -180,15 +180,15 @@ def write_httpd_config(self):
self.copyFile(self.apache2_ssl_24_conf, '/etc/httpd/conf.d/https_gluu.conf')

if base.os_type == 'suse':
self.copyFile(self.apache2_ssl_conf, self.https_gluu_fn)
self.copyFile(self.apache2_ssl_conf, self.https_jans_fn)

elif base.clone_type == 'rpm' and base.os_initdaemon == 'init':
self.copyFile(self.apache2_conf, '/etc/httpd/conf/httpd.conf')
self.copyFile(self.apache2_ssl_conf, self.https_gluu_fn)
self.copyFile(self.apache2_ssl_conf, self.https_jans_fn)

elif base.clone_type == 'deb':
self.copyFile(self.apache2_ssl_conf, self.https_gluu_fn)
self.run([paths.cmd_ln, '-s', self.https_gluu_fn,
self.copyFile(self.apache2_ssl_conf, self.https_jans_fn)
self.run([paths.cmd_ln, '-s', self.https_jans_fn,
'/etc/apache2/sites-enabled/https_gluu.conf'])

def installed(self):
Expand Down
4 changes: 3 additions & 1 deletion jans-ce-setup/setup_app/installers/rdbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def local_install(self):
packageUtils.check_and_install_packages()

if Config.rdbm_type == 'mysql':
if base.clone_type == 'rpm':
if base.os_type == 'suse':
self.restart('mysql')
elif base.clone_type == 'rpm':
self.restart('mysqld')
result, conn = self.dbUtils.mysqlconnection(log=False)
if not result:
Expand Down
18 changes: 16 additions & 2 deletions jans-ce-setup/setup_app/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DBUtils:
Base = None
session = None
cbm = None
mariadb = False

def bind(self, use_ssl=True, force=False):

Expand Down Expand Up @@ -118,8 +119,16 @@ def sqlconnection(self, log=True):
Session = sqlalchemy.orm.sessionmaker(bind=self.engine)
self.session = Session()
self.metadata = sqlalchemy.MetaData()
self.session.connection()
myconn = self.session.connection()

# are we running on MariaDB?
query = myconn.execute("select version()")
result = query.first()
if result and 'mariadb' in result[0].lower():
self.mariadb = True

base.logIt("{} Connection was successful".format(Config.rdbm_type.upper()))

return True, self.session

except Exception as e:
Expand All @@ -129,6 +138,8 @@ def sqlconnection(self, log=True):

@property
def json_dialects_instance(self):
if self.mariadb:
return sqlalchemy.dialects.mysql.LONGTEXT
return sqlalchemy.dialects.mysql.json.JSON if Config.rdbm_type == 'mysql' else sqlalchemy.dialects.postgresql.json.JSON

def mysqlconnection(self, log=True):
Expand Down Expand Up @@ -880,7 +891,10 @@ def import_ldif(self, ldif_files, bucket=None, force=None):
sqlalchObj = sqlalchCls()

for v in vals:
setattr(sqlalchObj, v, vals[v])
vval = vals[v]
if self.mariadb and isinstance(vval, dict):
vval = json.dumps(vals[v])
setattr(sqlalchObj, v, vval)

base.logIt("Adding {}".format(sqlalchObj.doc_id))
self.session.add(sqlalchObj)
Expand Down
4 changes: 2 additions & 2 deletions jans-ce-setup/setup_app/utils/properties_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,10 @@ def prompt_for_backend(self):
Config.rdbm_install_type = InstallTypes.LOCAL
Config.rdbm_type = 'mysql'
Config.rdbm_host = 'localhost'
Config.rdbm_user = 'gluu'
Config.rdbm_user = 'jans'
Config.rdbm_password = self.getPW(special='.*=+-()[]{}')
Config.rdbm_port = 3306
Config.rdbm_db = 'gluudb'
Config.rdbm_db = 'jansdb'

elif backend_type_str == 'Remote MySQL':
Config.opendj_install = InstallTypes.NONE
Expand Down

0 comments on commit e674315

Please sign in to comment.