How to execute a Bash script on a compute¶
Step 1. Drop¶
Drop the Bash component on a compute (e.g.,
Bash_1
).
Step 2. Write a script¶
Click on the Bash component to open the code editor.
Copy and paste the following script in the code editor and Save File.
#!/usr/bin/env bash
echo "Start configuring $NODE on compute $HOST"
echo "I have the ip address: $ip_address"
In this example, $NODE
, $HOST
, and $ip_address
are pre-defined environment variables. They will be resolved to the component name (e.g., Bash_1
), the hosted compute (e.g., Compute_1
), and the IP address of the compute (e.g., 10.0.0.3
), respectively at runtime.
Tip
For more environment variables, see Section Environment variables for Bash script.
(Alternative) Upload a script¶
If you have already had a script, you can upload it from your local machine:
Go to Artifacts / configure artifact.
Upload a Local file.
Select the file you have uploaded (e.g.,
my_file.sh
).
Expected result¶
During the deployment, the orchestrator executes Bash_1
on the Compute_1
and print out the logs:
Start configuring Bash_1 on compute Compute_1
I have the ip address: 10.0.0.3
Artifacts management¶
Go to Archive content. This section allows you to manage all file artifacts that you uploaded or created for your application.