diff options
-rwxr-xr-x | worker_manager | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/worker_manager b/worker_manager index 1d78207..92c2ad4 100755 --- a/worker_manager +++ b/worker_manager @@ -15,6 +15,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import base64 import json import logging import sys @@ -231,10 +232,30 @@ class WorkerManager(cliapp.Application): return exit_code def run_shell(shell_cmd): - return run_with_interp(['bash', '-xeuc'], shell_cmd) + params = work.get('parameters', {}) + params_json = json.dumps(params) + params_text = base64.b64encode( + params_json.encode('utf8')).decode('utf8') + prefix = [ + 'params() { echo -n "%s" | base64 -d; }' % params_text, + ] + prefix_text = ''.join('{}\n'.format(line) for line in prefix) + script = prefix_text + shell_cmd + return run_with_interp(['bash', '-xeuc'], script) def run_python(python_cmd): - return run_with_interp(['python3', '-c'], python_cmd) + params = work.get('parameters', {}) + params_json = json.dumps(params) + params_text = base64.b64encode( + params_json.encode('utf8')).decode('utf8') + prefix = [ + 'import base64, json', + 'params = json.loads(base64.b64decode(' + ' "{}").decode("utf8"))'.format(params_text) + ] + prefix_text = ''.join('{}\n'.format(line) for line in prefix) + script = prefix_text + python_cmd + return run_with_interp(['python3', '-c'], script) def run_debootstrap(step): shell_cmd = "sudo debootstrap '{}' . '{}'".format( |