mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 11:12:15 +03:00
unregister show message fixed
This commit is contained in:
parent
9232b6439f
commit
8991f8d768
3 changed files with 58 additions and 46 deletions
|
@ -240,6 +240,29 @@ class AhenkDaemon(BaseDaemon):
|
|||
Util.create_file(System.Ahenk.fifo_file())
|
||||
Util.set_permission(System.Ahenk.fifo_file(), '600')
|
||||
|
||||
def disable_local_users(self):
|
||||
|
||||
self.logger.info('Local users disable action start..')
|
||||
conf_manager = Scope.get_instance().get_configuration_manager()
|
||||
|
||||
if conf_manager.has_section('MACHINE'):
|
||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||
self.logger.info('User disabled value=' + str(user_disabled))
|
||||
if user_disabled == '0':
|
||||
self.logger.info('local user disabling')
|
||||
Scope.get_instance().get_registration().disable_local_users()
|
||||
|
||||
conf_manager.set('MACHINE', 'user_disabled', '1')
|
||||
|
||||
with open('/etc/ahenk/ahenk.conf', 'w') as configfile:
|
||||
self.logger.info('oepning config file ')
|
||||
conf_manager.write(configfile)
|
||||
|
||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||
self.logger.info('User succesfully disabled value=' + str(user_disabled))
|
||||
else:
|
||||
self.logger.info('users already disabled')
|
||||
|
||||
def run(self):
|
||||
""" docstring"""
|
||||
print('Ahenk running...')
|
||||
|
@ -287,27 +310,9 @@ class AhenkDaemon(BaseDaemon):
|
|||
|
||||
self.check_registration()
|
||||
|
||||
self.is_registered()
|
||||
#self.is_registered()
|
||||
|
||||
conf_manager= global_scope.get_configuration_manager()
|
||||
|
||||
if conf_manager.has_section('MACHINE'):
|
||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||
self.logger.info('User disabled value='+ str(user_disabled))
|
||||
if user_disabled == '0':
|
||||
self.logger.info('local user disabling')
|
||||
global_scope.get_registration().disable_local_users()
|
||||
|
||||
conf_manager.set('MACHINE', 'user_disabled', '1')
|
||||
|
||||
with open('/etc/ahenk/ahenk.conf', 'w') as configfile:
|
||||
self.logger.info('oepning config file ')
|
||||
conf_manager.write(configfile)
|
||||
|
||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||
self.logger.info('User succesfully disabled value=' + str(user_disabled))
|
||||
else :
|
||||
self.logger.info('users already disabled')
|
||||
self.disable_local_users()
|
||||
|
||||
#self.logger.info('Ahenk was registered')
|
||||
|
||||
|
|
|
@ -352,13 +352,17 @@ class Registration:
|
|||
|
||||
|
||||
def purge_and_unregister(self):
|
||||
try:
|
||||
user_name = self.db_service.select_one_result('session', 'username')
|
||||
display = self.db_service.select_one_result('session', 'display')
|
||||
|
||||
self.logger.info('Ahenk conf cleaned')
|
||||
self.logger.info('Ahenk conf cleaning from db')
|
||||
self.unregister()
|
||||
self.logger.info('Purge ldap packages')
|
||||
Util.execute("sudo apt purge libpam-ldap libnss-ldap ldap-utils -y")
|
||||
#self.logger.info('Purge ahenk packages')
|
||||
#Util.execute("sudo apt purge ahenk ahenk-* -y")
|
||||
# self.logger.info('Purge ahenk packages')
|
||||
# Util.execute("sudo apt purge ahenk ahenk-* -y")
|
||||
Util.execute("sudo apt autoremove -y")
|
||||
self.change_configs_after_purge()
|
||||
self.logger.info('purging successfull')
|
||||
|
@ -369,14 +373,16 @@ class Registration:
|
|||
self.logger.info('Enable Users')
|
||||
self.enable_local_users()
|
||||
|
||||
user_name = self.db_service.select_one_result('session', 'username')
|
||||
display = self.db_service.select_one_result('session', 'display')
|
||||
Util.show_message(user_name, display, "Ahenk etki alanından çıkarılmıştır.", "")
|
||||
|
||||
Util.show_message(user_name,display,"Ahenk etki alanından çıkarılmıştır.", "")
|
||||
|
||||
if Util.show_message(user_name,display,"Değişikliklerin etkili olması için sistem yeniden başlatmanız gerekmektedir.",""):
|
||||
if Util.show_message(user_name, display,
|
||||
"Değişikliklerin etkili olması için sistem yeniden başlatmanız gerekmektedir.", ""):
|
||||
Util.shutdown()
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error("Error while running purge_and_unregister process.. Error Message " + str(e))
|
||||
|
||||
|
||||
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||
#sys.exit(2)
|
||||
|
||||
|
@ -475,6 +481,7 @@ class Registration:
|
|||
file.close()
|
||||
print('Ahenk cleaned.')
|
||||
except Exception as e:
|
||||
self.logger.error("Error while running clean command. Error Message " + str(e))
|
||||
print('Error while running clean command. Error Message {0}'.format(str(e)))
|
||||
|
||||
def enable_local_users(self):
|
||||
|
|
|
@ -332,7 +332,7 @@ class Util:
|
|||
Util.execute('export DISPLAY={0}; su - {1} -c \'{2}\''.format(display, user, inner_command))
|
||||
|
||||
@staticmethod
|
||||
def show_message(username,display=':0',message="", title=""):
|
||||
def show_message(username,display=':0',message='', title=''):
|
||||
ask_path = '/usr/share/ahenk/base/agreement/confirm.py'
|
||||
try:
|
||||
|
||||
|
@ -352,14 +352,14 @@ class Util:
|
|||
|
||||
else:
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
except Exception as e :
|
||||
print("Error when showing message " + str(e))
|
||||
|
||||
return None;
|
||||
|
||||
@staticmethod
|
||||
def show_registration_message(login_user_name,message,title,host=None):
|
||||
|
||||
ask_path = '/usr/share/ahenk/base/agreement/ahenkmessage.py'
|
||||
|
||||
display_number = ":0"
|
||||
|
||||
if host is None:
|
||||
|
@ -375,7 +375,7 @@ class Util:
|
|||
|
||||
pout = str(p_out).replace('\n', '')
|
||||
|
||||
return pout\
|
||||
return pout
|
||||
|
||||
@staticmethod
|
||||
def show_unregistration_message(login_user_name,display_number,message,title):
|
||||
|
|
Loading…
Reference in a new issue