core: Support for outRun bang

can be used to execute commands outsie of the main shell script
main
Mirko Brombin 2 years ago
parent 4143bcb06b
commit 390db5620f

@ -29,6 +29,7 @@ class Processor:
@staticmethod
def run(log_path, pre_run, post_run, commands):
commands = pre_run + commands + post_run
out_run = ""
abroot_bin = shutil.which("abroot")
logger.info("processing the following commands: \n%s" %
@ -44,6 +45,11 @@ class Processor:
for command in commands:
if command.startswith("!noSudo"):
command = command.replace("!noSudo", "sudo -u $USER")
# outRun band is used to run a command outside of the main
# shell script.
if command.startswith("!outRun"):
out_run += command.replace("!outRun", "") + "\n"
f.write(f"{command}\n")
@ -89,4 +95,9 @@ class Processor:
if os.path.exists(autostart_file):
os.remove(autostart_file)
# run the outRun commands
if out_run:
logger.info("running outRun commands: \n%s" % out_run)
subprocess.run(out_run, shell=True)
return True

Loading…
Cancel
Save