forked from shaba/openuds
Minor fixes for actor for linux
This commit is contained in:
parent
a83e218679
commit
bd3d0dd006
@ -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')
|
||||
|
@ -70,6 +70,8 @@ def initCfg():
|
||||
cfg = None
|
||||
break
|
||||
|
||||
return cfg
|
||||
|
||||
|
||||
class CommonService(object):
|
||||
def __init__(self):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user