From 151d35459e08b6af710461cc18ecfaa728a283e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 28 Nov 2016 09:47:31 +0100 Subject: [PATCH] Added execution of script on /etc/udsactor/post on Linux Actor after getting "ready" on machine... --- actors/src/udsactor/linux/UDSActorService.py | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/actors/src/udsactor/linux/UDSActorService.py b/actors/src/udsactor/linux/UDSActorService.py index 3d90fb2d..1be95988 100644 --- a/actors/src/udsactor/linux/UDSActorService.py +++ b/actors/src/udsactor/linux/UDSActorService.py @@ -44,9 +44,14 @@ from udsactor.linux.daemon import Daemon from udsactor.linux import renamer import sys -import time +import os +import stat +import subprocess + +POST_CMD = '/etc/udsactor/post' + try: - from prctl import set_proctitle + from prctl import set_proctitle # @UnresolvedImport except Exception: # Platform may not include prctl, so in case it's not available, we let the "name" as is def set_proctitle(_): pass @@ -106,6 +111,21 @@ class UDSActorSvc(Daemon, CommonService): logger.debug('Reboot has been requested, stopping service') return + # Execute script in /etc/udsactor/post after interacting with broker, if no reboot is requested ofc + # This will be executed only when machine gets "ready" + try: + + if os.path.isfile(POST_CMD): + if (os.stat(POST_CMD).st_mode & stat.S_IXUSR) != 0: + subprocess.call('/etc/udsactor/post') + else: + logger.info('POST file exists but it it is not executable (needs execution permission by root)') + else: + logger.info('POST file not found & not executed') + except Exception as e: + # Ignore output of execution command + logger.error('Executing post command give') + self.initIPC() # *********************