mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-12-22 18:42:16 +03:00
added default config class for sssd settings
This commit is contained in:
parent
efd469dd4b
commit
10369afda0
4 changed files with 77 additions and 18 deletions
34
debian/ahenk.postinst
vendored
34
debian/ahenk.postinst
vendored
|
@ -12,23 +12,23 @@ if [ ! -d /etc/ahenk ]; then
|
|||
|
||||
fi
|
||||
|
||||
# update pardus21 sssd conf changes when update pardus from 24 to 25
|
||||
if [ -d /etc/ahenk ]; then
|
||||
if [ -f /etc/default/sssd ]; then
|
||||
if ! grep -Fxq 'LC_ALL="tr_CY.UTF-8"' /etc/default/sssd
|
||||
then
|
||||
echo 'LC_ALL="tr_CY.UTF-8"' >> /etc/default/sssd
|
||||
systemctl restart sssd.service
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /etc/ahenk/ad_info ]; then
|
||||
if [ -f /etc/sssd/sssd.conf ]; then
|
||||
sed -i 's/ad_domain/ad_server/g' /etc/sssd/sssd.conf
|
||||
systemctl restart sssd.service
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
## update pardus21 sssd conf changes when update pardus from 24 to 25
|
||||
#if [ -d /etc/ahenk ]; then
|
||||
# if [ -f /etc/default/sssd ]; then
|
||||
# if ! grep -Fxq 'LC_ALL="tr_CY.UTF-8"' /etc/default/sssd
|
||||
# then
|
||||
# echo 'LC_ALL="tr_CY.UTF-8"' >> /etc/default/sssd
|
||||
# systemctl restart sssd.service
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# if [ -f /etc/ahenk/ad_info ]; then
|
||||
# if [ -f /etc/sssd/sssd.conf ]; then
|
||||
# sed -i 's/ad_domain/ad_server/g' /etc/sssd/sssd.conf
|
||||
# systemctl restart sssd.service
|
||||
# fi
|
||||
# fi
|
||||
#fi
|
||||
|
||||
systemctl enable ahenk
|
||||
systemctl start ahenk
|
||||
|
|
|
@ -30,6 +30,7 @@ from base.scope import Scope
|
|||
from base.system.system import System
|
||||
from base.task.task_manager import TaskManager
|
||||
from base.util.util import Util
|
||||
from base.default_config.default_config import DefaultConfig
|
||||
from easygui import msgbox
|
||||
|
||||
sys.path.append('../..')
|
||||
|
@ -274,6 +275,10 @@ class AhenkDaemon(BaseDaemon):
|
|||
else:
|
||||
self.logger.info('local users will not be disabled because local_user_paramater is FALSE')
|
||||
|
||||
def default_settings(self):
|
||||
default_config = DefaultConfig()
|
||||
default_config.check_sssd_settings()
|
||||
|
||||
def run(self):
|
||||
""" docstring"""
|
||||
print('Ahenk running...')
|
||||
|
@ -319,6 +324,8 @@ class AhenkDaemon(BaseDaemon):
|
|||
self.init_execution_manager()
|
||||
self.logger.info('Execution Manager was set')
|
||||
|
||||
self.default_settings()
|
||||
|
||||
self.check_registration()
|
||||
|
||||
self.is_registered()
|
||||
|
@ -341,7 +348,6 @@ class AhenkDaemon(BaseDaemon):
|
|||
# if registration.is_ldap_registered() is False:
|
||||
# logger.debug('Attempting to registering ldap')
|
||||
# registration.ldap_registration_request() #TODO work on message
|
||||
|
||||
self.logger.info('LDAP registration of Ahenk is completed')
|
||||
|
||||
self.messenger.send_direct_message('test')
|
||||
|
|
0
src/base/default_config/__init__.py
Normal file
0
src/base/default_config/__init__.py
Normal file
53
src/base/default_config/default_config.py
Normal file
53
src/base/default_config/default_config.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# checked config when restarted agent service. Example, sssd language settings..
|
||||
|
||||
from base.scope import Scope
|
||||
from base.util.util import Util
|
||||
|
||||
|
||||
class DefaultConfig:
|
||||
|
||||
def __init__(self):
|
||||
scope = Scope().get_instance()
|
||||
self.logger = scope.get_logger()
|
||||
|
||||
def check_sssd_settings(self):
|
||||
# configure sssd for language environment
|
||||
sssd_language_conf = "/etc/default/sssd"
|
||||
sssd_conf_path = "/etc/sssd/sssd.conf"
|
||||
ad_info = "/etc/ahenk/ad_info"
|
||||
registration = Scope.get_instance().get_registration()
|
||||
if registration.is_registered() and Util.is_exist(sssd_language_conf):
|
||||
file_default_sssd = open(sssd_language_conf, 'r')
|
||||
file_data = file_default_sssd.read()
|
||||
file_default_sssd.close()
|
||||
|
||||
if "LC_ALL=\"tr_CY.UTF-8\"" not in file_data:
|
||||
file_data = file_data + "\n" + "LC_ALL=\"tr_CY.UTF-8\""
|
||||
self.logger.info("added language environment for sssd")
|
||||
file_default_sssd = open(sssd_language_conf, 'w')
|
||||
file_default_sssd.write(file_data)
|
||||
file_default_sssd.close()
|
||||
Util.execute("systemctl restart sssd.service")
|
||||
|
||||
if registration.is_registered() and Util.is_exist(sssd_conf_path) and Util.is_exist(ad_info):
|
||||
sssd_conf_data = Util.read_file_by_line(sssd_conf_path)
|
||||
|
||||
isExist = False
|
||||
for line in sssd_conf_data:
|
||||
if "ad_domain" in line:
|
||||
isExist = True
|
||||
if isExist:
|
||||
sssd_conf_temp = open(sssd_conf_path, 'w')
|
||||
for line in sssd_conf_data:
|
||||
if "ad_domain" in line:
|
||||
line = line.replace("ad_domain", "ad_server")
|
||||
sssd_conf_temp.write(line)
|
||||
sssd_conf_temp.close()
|
||||
Util.execute("systemctl restart sssd.service")
|
||||
self.logger.info("replaced ad_domain parameter with ad_server")
|
||||
sssd_conf_temp.close()
|
||||
|
||||
|
Loading…
Reference in a new issue