started new script running system
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Mathieu Broillet 2023-06-15 17:13:34 +02:00
parent 25b208094d
commit 609cc0ef24
No known key found for this signature in database
GPG Key ID: 7D4F25BC50A0AA32
2 changed files with 24 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import logging
from pathlib import Path
from typing import TYPE_CHECKING
from ..utils import commands_utils
from . import lxc_utils
from ..utils.resources_utils import get_path
if TYPE_CHECKING:
@ -174,9 +174,9 @@ def run_steps(lxc: LXC):
# Support for scripts
case "script":
commands_utils.run_script(lxc, step)
lxc_utils.run_script_parser(lxc, step)
case "file_create":
commands_utils.create_file_in_lxc(lxc, step["path"], optional(step["permission"], 644))
lxc.create_file(step["path"], optional(step["permission"], 644))
case "file_copy":
commands_utils.copy_local_file_to_lxc(lxc, get_path(lxc, step["path"]), step["destination"])
case "folder":

View File

@ -117,3 +117,24 @@ def generate_pct_command_for_lxc(lxc: LXC, create: bool = True):
# TODO: add gateway4
# f"ip6={self.ipv6},gw6={self.gateway6},trunks={self.vlan} " \ # TODO
return pct_command
def run_script_parser(lxc: LXC, step: dict):
# 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"):
lxc.install_package("bash")
# # Run local script
# if "path" in step:
# path = get_path(lxc, step["local_path"])
# _run_local_script_on_lxc(lxc, path)
#
# # Run remote script
# elif "url" in step:
# _run_remote_script_on_lxc(lxc, step["url"])
#
# # Run script in LXC
# elif "lxc_path" in step:
# path = get_path(lxc, step["lxc_path"])
# _run_script_on_lxc(lxc, path)