From 88f4cdf14fd8617152486a485bbd2ecaca71ac47 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Mon, 12 Jun 2023 22:05:21 +0200 Subject: [PATCH] fixed running bash script remotely and install package error --- src/utils/lxc_commands_utils.py | 11 ++++++++--- src/utils/proxmox_utils.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/lxc_commands_utils.py b/src/utils/lxc_commands_utils.py index 400fa83..47c6adc 100644 --- a/src/utils/lxc_commands_utils.py +++ b/src/utils/lxc_commands_utils.py @@ -17,6 +17,11 @@ def run_script(lxc, step): Typically read from the "creation/steps/" in JSON file """ + # Install bash if not installed + # Sometimes only ash or sh are installed, which doesn't work for some scripts + if not lxc.has_program("bash"): + install_package(lxc, "bash") + # Run local script if "path" in step: _run_local_script_on_lxc(lxc, step["path"]) @@ -42,7 +47,7 @@ def _run_local_script_on_lxc(lxc, path: "Path to the script on the machine runni path = get_path(lxc, path) with open(path, "r") as file: script = file.read() - lxc.run_command("'bash -s' <<'ENDSSH'\n" + script) + lxc.run_command("bash <