bash-1.7.0
2 minute read
KOSI Plugin bash Version 1.7.0
Summary
The bash
plugin allows users to execute shell commands within a Bash environment. It is useful for running system commands, scripting automation tasks, or performing custom operations that require command-line execution within a KOSI package. This plugin ensures that commands are executed inside a Bash shell, which provides compatibility with shell scripting syntax and built-in commands. Supports command chaining using ;
.
Keys
Key | Description | |
---|---|---|
command | Mandatory | Contains a string representing a bash command or a sequence of commands to be executed. Multiple commands can be specified, separated by a semicolon (; ). |
Examples
Example 1
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
install
{
cmd(command = "echo Using the bash plugin.");
bash(command = "echo Hello World!");
}
Output
2025-02-26 15:17:00 Info: use plugin bash if available
2025-02-26 15:17:00 Info: Executing with non sudo privilegs
2025-02-26 15:17:00 Info: Using the bash plugin.
2025-02-26 15:17:00 Info: Executing with non sudo privilegs
2025-02-26 15:17:00 Info: Hello World!
2025-02-26 15:17:00 Info: Installation successful.
Example 2
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
install
{
cmd(command = "echo Using the bash plugin.");
bash(command = "echo 1.Hello;echo 2.World;echo 3.Hello World.");
}
Output
2025-02-26 15:18:28 Info: run cmd plugin
2025-02-26 15:18:28 Info: use plugin bash if available
2025-02-26 15:18:28 Info: Executing with non sudo privilegs
2025-02-26 15:18:28 Info: Using the bash plugin.
2025-02-26 15:18:28 Info: Executing with non sudo privilegs
2025-02-26 15:18:28 Info: 1.Hello
2.World
3.Hello World.
2025-02-26 15:18:28 Info: Installation successful.
Example 3
Using bash
with the set
and if
plugins
This example shows the interaction of several plug-ins.
In this example, we use the bash
plugin together with the set
and if
plugins to check a condition (which is set before) before executing a bash command:
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-bash-if";
description = "Example using bash with set and if";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
install
{
set
(
variable = "myVar";
value = "Hello";
);
if (condition = "$vars.myVar$ = 'Hello'") then
{
bash(command = "echo Variable is 'Hello'");
}
else
{
bash(command = "echo Variable is not 'Hello'");
}
}
Expected Output
If myVar
is Hello
:
2025-02-26 15:18:28 Info: Variable is 'Hello'
If myVar
is not Hello
:
2025-02-26 15:18:28 Info: Variable is not 'Hello'