diff options
| author | Abdulwasiu Apalowo <abdulwasiuapalowo@gmail.com> | 2023-03-29 15:42:15 +0100 |
|---|---|---|
| committer | Abdulwasiu Apalowo <abdulwasiuapalowo@gmail.com> | 2023-05-03 15:09:02 +0100 |
| commit | 596ba5e020c2964ca324cceb8a4834cfe70057cb (patch) | |
| tree | c9a00f5e590533be3447b1eafc78b2c2c4b2cd06 | |
| parent | b8a809bf6ca5334b337ce599014043d69a734109 (diff) | |
| download | libvirt-ci-596ba5e020c2964ca324cceb8a4834cfe70057cb.zip libvirt-ci-596ba5e020c2964ca324cceb8a4834cfe70057cb.tar.gz libvirt-ci-596ba5e020c2964ca324cceb8a4834cfe70057cb.tar.bz2 | |
containers: change the mode bits of --script argument
The file passed to --script argument is made an executable file
before mounting it in the container.
The documentation is updated so that users don't have to manually
perform this change.
Signed-off-by: Abdulwasiu Apalowo <abdulwasiuapalowo@gmail.com>
| -rw-r--r-- | docs/containers.rst | 8 | ||||
| -rw-r--r-- | lcitool/containers/containers.py | 8 |
2 files changed, 7 insertions, 9 deletions
diff --git a/docs/containers.rst b/docs/containers.rst index abaa406..5873b12 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -82,12 +82,8 @@ home directory inside the container, and the working directory is switched to the home directory to make execution easier. The script file is mounted to the *script* file in the home directory -inside the container. Ensure the file is an executable by running: - -:: - - chmod +x <path_to_your_script> - +inside the container. The script is made executable before the mount is +performed. It can also be used as a standalone script (e.g an ``echo hello" script``). diff --git a/lcitool/containers/containers.py b/lcitool/containers/containers.py index e026c22..0d5041b 100644 --- a/lcitool/containers/containers.py +++ b/lcitool/containers/containers.py @@ -194,9 +194,11 @@ class Container(ABC): ] if script: - script_file = shutil.copy2( - script, Path(tempdir, "script") - ) + script_file = Path(shutil.copy2(script, Path(tempdir, "script"))) + + # make the script an executable file + script_file.chmod(script_file.stat().st_mode | 0o111) + script_mount = f"{script_file}:{user_home}/script:z" engine_args_.extend([ "--volume", script_mount |
