diff --git a/actors/src/udsactor/linux/UDSActorService.py b/actors/src/udsactor/linux/UDSActorService.py index 1be95988..3569b97a 100644 --- a/actors/src/udsactor/linux/UDSActorService.py +++ b/actors/src/udsactor/linux/UDSActorService.py @@ -36,6 +36,7 @@ from udsactor import operations from udsactor.service import CommonService from udsactor.service import initCfg from udsactor.service import IPC_PORT + from udsactor import ipc from udsactor.log import logger @@ -58,6 +59,8 @@ except Exception: # Platform may not include prctl, so in case it's not availab class UDSActorSvc(Daemon, CommonService): + rebootMachineAfterOp = False + def __init__(self, args=None): Daemon.__init__(self, '/var/run/udsa.pid') CommonService.__init__(self) @@ -67,6 +70,12 @@ class UDSActorSvc(Daemon, CommonService): Renames the computer, and optionally sets a password for an user before this ''' + hostName = operations.getComputerName() + + if hostName.lower() == name.lower(): + logger.info('Computer name is now {}'.format(hostName)) + self.setReady() + return # Check for password change request for an user if user is not None: @@ -80,13 +89,20 @@ class UDSActorSvc(Daemon, CommonService): 'Could not change password for user {} (maybe invalid current password is configured at broker): {} '.format(user, unicode(e))) renamer.rename(name) - self.setReady() + + if self.rebootMachineAfterOp is False: + self.setReady() + else: + logger.info('Rebooting computer to activate new name {}'.format(name)) + self.reboot() + def joinDomain(self, name, domain, ou, account, password): logger.fatal('Join domain is not supported on linux platforms right now') def run(self): - initCfg() + localCfg = initCfg() # Gets a local copy of config to get "reboot" + self.rebootMachineAfterOp = localCfg.get('reboot', 'false') == 'true' logger.debug('Running Daemon') set_proctitle('UDSActorDaemon') diff --git a/actors/src/udsactor/service.py b/actors/src/udsactor/service.py index 252b94b3..024a7532 100644 --- a/actors/src/udsactor/service.py +++ b/actors/src/udsactor/service.py @@ -70,6 +70,8 @@ def initCfg(): cfg = None break + return cfg + class CommonService(object): def __init__(self): diff --git a/actors/src/udsactor/windows/UDSActorService.py b/actors/src/udsactor/windows/UDSActorService.py index 500c44bf..cc31386d 100644 --- a/actors/src/udsactor/windows/UDSActorService.py +++ b/actors/src/udsactor/windows/UDSActorService.py @@ -114,7 +114,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): operations.renameComputer(name) # Reboot just after renaming - logger.info('Rebooting computer got activate new name {}'.format(name)) + logger.info('Rebooting computer to activate new name {}'.format(name)) self.reboot() def oneStepJoin(self, name, domain, ou, account, password):