From 9054c233f41ba002ec05345623144040ce608343 Mon Sep 17 00:00:00 2001 From: Charlie Powell Date: Thu, 15 Aug 2024 00:41:04 -0400 Subject: [PATCH 1/2] Proposed work for amidaware/community-scripts#245 Modify the load_community_scripts logic to add env and run_as_user keys. --- api/tacticalrmm/scripts/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/tacticalrmm/scripts/models.py b/api/tacticalrmm/scripts/models.py index 45ab2b5316..ae09adbc0f 100644 --- a/api/tacticalrmm/scripts/models.py +++ b/api/tacticalrmm/scripts/models.py @@ -118,8 +118,12 @@ def load_community_scripts(cls): args = script["args"] if "args" in script.keys() else [] + env = script["env"] if "env" in script.keys() else [] + syntax = script["syntax"] if "syntax" in script.keys() else "" + run_as_user = script["run_as_user"] if "run_as_user" in script.keys() else False + supported_platforms = ( script["supported_platforms"] if "supported_platforms" in script.keys() @@ -135,7 +139,9 @@ def load_community_scripts(cls): i.shell = script["shell"] i.default_timeout = default_timeout i.args = args + i.env_vars = env i.syntax = syntax + i.run_as_user = run_as_user i.filename = script["filename"] i.supported_platforms = supported_platforms @@ -163,8 +169,10 @@ def load_community_scripts(cls): category=category, default_timeout=default_timeout, args=args, + env_vars=env, filename=script["filename"], syntax=syntax, + run_as_user=run_as_user, supported_platforms=supported_platforms, ) # new_script.hash_script_body() # also saves script From 706757d215943c07aba9a74e37cadc1a04118edf Mon Sep 17 00:00:00 2001 From: Charlie Powell Date: Thu, 15 Aug 2024 00:57:04 -0400 Subject: [PATCH 2/2] Black didn't like the format of that line whatever, quick fix. --- api/tacticalrmm/scripts/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/tacticalrmm/scripts/models.py b/api/tacticalrmm/scripts/models.py index ae09adbc0f..5c9b0d2968 100644 --- a/api/tacticalrmm/scripts/models.py +++ b/api/tacticalrmm/scripts/models.py @@ -122,7 +122,9 @@ def load_community_scripts(cls): syntax = script["syntax"] if "syntax" in script.keys() else "" - run_as_user = script["run_as_user"] if "run_as_user" in script.keys() else False + run_as_user = ( + script["run_as_user"] if "run_as_user" in script.keys() else False + ) supported_platforms = ( script["supported_platforms"]